/* cache-manager.c generated by valac 0.56.19, the Vala compiler
 * generated from cache-manager.vala, do not modify */

#include "protonplus_core.h"
#include <glib.h>
#include <gio/gio.h>
#include <glib/gstdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include <gobject/gvaluecollector.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

typedef struct _Block81Data Block81Data;
typedef struct _ProtonPlusUtilsCacheManagerWaitForCacheStateChangeData ProtonPlusUtilsCacheManagerWaitForCacheStateChangeData;
typedef struct _ProtonPlusUtilsCacheManagerBeginCacheOperationData ProtonPlusUtilsCacheManagerBeginCacheOperationData;
typedef struct _ProtonPlusUtilsCacheManagerClearCacheData ProtonPlusUtilsCacheManagerClearCacheData;
typedef struct _ProtonPlusUtilsParamSpecCacheManager ProtonPlusUtilsParamSpecCacheManager;
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _Block81Data {
	int _ref_count_;
	gpointer _async_data_;
};

struct _ProtonPlusUtilsCacheManagerWaitForCacheStateChangeData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	Block81Data* _data81_;
};

struct _ProtonPlusUtilsCacheManagerBeginCacheOperationData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	guint _tmp0_;
};

struct _ProtonPlusUtilsCacheManagerClearCacheData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	gboolean result;
	gboolean success;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
};

struct _ProtonPlusUtilsParamSpecCacheManager {
	GParamSpec parent_instance;
};

static gpointer proton_plus_utils_cache_manager_parent_class = NULL;
static guint proton_plus_utils_cache_manager_active_cache_operations;
static guint proton_plus_utils_cache_manager_active_cache_operations = (guint) 0;
static gboolean proton_plus_utils_cache_manager_clearing_cache;
static gboolean proton_plus_utils_cache_manager_clearing_cache = FALSE;

static void proton_plus_utils_cache_manager_wait_for_cache_state_change_data_free (gpointer _data);
static void proton_plus_utils_cache_manager_wait_for_cache_state_change (GAsyncReadyCallback _callback_,
                                                                  gpointer _user_data_);
static void proton_plus_utils_cache_manager_wait_for_cache_state_change_finish (GAsyncResult* _res_);
static gboolean proton_plus_utils_cache_manager_wait_for_cache_state_change_co (ProtonPlusUtilsCacheManagerWaitForCacheStateChangeData* _data_);
static Block81Data* block81_data_ref (Block81Data* _data81_);
static void block81_data_unref (void * _userdata_);
static gboolean __lambda21_ (Block81Data* _data81_);
static gboolean ___lambda21__gsource_func (gpointer self);
static void proton_plus_utils_cache_manager_begin_cache_operation_data_free (gpointer _data);
static gboolean proton_plus_utils_cache_manager_begin_cache_operation_co (ProtonPlusUtilsCacheManagerBeginCacheOperationData* _data_);
static void proton_plus_utils_cache_manager_begin_cache_operation_ready (GObject* source_object,
                                                                  GAsyncResult* _res_,
                                                                  gpointer _user_data_);
static void proton_plus_utils_cache_manager_clear_cache_data_free (gpointer _data);
static gboolean proton_plus_utils_cache_manager_clear_cache_co (ProtonPlusUtilsCacheManagerClearCacheData* _data_);
static void proton_plus_utils_cache_manager_clear_cache_ready (GObject* source_object,
                                                        GAsyncResult* _res_,
                                                        gpointer _user_data_);
static void proton_plus_utils_cache_manager_finalize (ProtonPlusUtilsCacheManager * obj);
static GType proton_plus_utils_cache_manager_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static void
proton_plus_utils_cache_manager_wait_for_cache_state_change_data_free (gpointer _data)
{
	ProtonPlusUtilsCacheManagerWaitForCacheStateChangeData* _data_;
	_data_ = _data;
	g_slice_free (ProtonPlusUtilsCacheManagerWaitForCacheStateChangeData, _data_);
}

static void
proton_plus_utils_cache_manager_wait_for_cache_state_change (GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_)
{
	ProtonPlusUtilsCacheManagerWaitForCacheStateChangeData* _data_;
	_data_ = g_slice_new0 (ProtonPlusUtilsCacheManagerWaitForCacheStateChangeData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, proton_plus_utils_cache_manager_wait_for_cache_state_change_data_free);
	proton_plus_utils_cache_manager_wait_for_cache_state_change_co (_data_);
}

static void
proton_plus_utils_cache_manager_wait_for_cache_state_change_finish (GAsyncResult* _res_)
{
	ProtonPlusUtilsCacheManagerWaitForCacheStateChangeData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static Block81Data*
block81_data_ref (Block81Data* _data81_)
{
	g_atomic_int_inc (&_data81_->_ref_count_);
	return _data81_;
}

static void
block81_data_unref (void * _userdata_)
{
	Block81Data* _data81_;
	_data81_ = (Block81Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data81_->_ref_count_)) {
		g_slice_free (Block81Data, _data81_);
	}
}

static gboolean
__lambda21_ (Block81Data* _data81_)
{
	gboolean result;
	proton_plus_utils_cache_manager_wait_for_cache_state_change_co (_data81_->_async_data_);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda21__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda21_ (self);
	return result;
}

static gboolean
proton_plus_utils_cache_manager_wait_for_cache_state_change_co (ProtonPlusUtilsCacheManagerWaitForCacheStateChangeData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data81_ = g_slice_new0 (Block81Data);
	_data_->_data81_->_ref_count_ = 1;
	_data_->_data81_->_async_data_ = _data_;
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 10, ___lambda21__gsource_func, block81_data_ref (_data_->_data81_), block81_data_unref);
	_data_->_state_ = 1;
	return FALSE;
	_state_1:
	;
	block81_data_unref (_data_->_data81_);
	_data_->_data81_ = NULL;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
proton_plus_utils_cache_manager_begin_cache_operation_data_free (gpointer _data)
{
	ProtonPlusUtilsCacheManagerBeginCacheOperationData* _data_;
	_data_ = _data;
	g_slice_free (ProtonPlusUtilsCacheManagerBeginCacheOperationData, _data_);
}

void
proton_plus_utils_cache_manager_begin_cache_operation (GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_)
{
	ProtonPlusUtilsCacheManagerBeginCacheOperationData* _data_;
	_data_ = g_slice_new0 (ProtonPlusUtilsCacheManagerBeginCacheOperationData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, proton_plus_utils_cache_manager_begin_cache_operation_data_free);
	proton_plus_utils_cache_manager_begin_cache_operation_co (_data_);
}

void
proton_plus_utils_cache_manager_begin_cache_operation_finish (GAsyncResult* _res_)
{
	ProtonPlusUtilsCacheManagerBeginCacheOperationData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
proton_plus_utils_cache_manager_begin_cache_operation_ready (GObject* source_object,
                                                             GAsyncResult* _res_,
                                                             gpointer _user_data_)
{
	ProtonPlusUtilsCacheManagerBeginCacheOperationData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	proton_plus_utils_cache_manager_begin_cache_operation_co (_data_);
}

static gboolean
proton_plus_utils_cache_manager_begin_cache_operation_co (ProtonPlusUtilsCacheManagerBeginCacheOperationData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	while (TRUE) {
		if (!proton_plus_utils_cache_manager_clearing_cache) {
			break;
		}
		_data_->_state_ = 1;
		proton_plus_utils_cache_manager_wait_for_cache_state_change (proton_plus_utils_cache_manager_begin_cache_operation_ready, _data_);
		return FALSE;
		_state_1:
		proton_plus_utils_cache_manager_wait_for_cache_state_change_finish (_data_->_res_);
	}
	_data_->_tmp0_ = proton_plus_utils_cache_manager_active_cache_operations;
	proton_plus_utils_cache_manager_active_cache_operations = _data_->_tmp0_ + 1;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

void
proton_plus_utils_cache_manager_end_cache_operation (void)
{
	guint _tmp0_;
	_vala_assert (proton_plus_utils_cache_manager_active_cache_operations > ((guint) 0), "active_cache_operations > 0");
	_tmp0_ = proton_plus_utils_cache_manager_active_cache_operations;
	proton_plus_utils_cache_manager_active_cache_operations = _tmp0_ - 1;
}

static void
proton_plus_utils_cache_manager_clear_cache_data_free (gpointer _data)
{
	ProtonPlusUtilsCacheManagerClearCacheData* _data_;
	_data_ = _data;
	g_slice_free (ProtonPlusUtilsCacheManagerClearCacheData, _data_);
}

void
proton_plus_utils_cache_manager_clear_cache (GAsyncReadyCallback _callback_,
                                             gpointer _user_data_)
{
	ProtonPlusUtilsCacheManagerClearCacheData* _data_;
	_data_ = g_slice_new0 (ProtonPlusUtilsCacheManagerClearCacheData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, proton_plus_utils_cache_manager_clear_cache_data_free);
	proton_plus_utils_cache_manager_clear_cache_co (_data_);
}

gboolean
proton_plus_utils_cache_manager_clear_cache_finish (GAsyncResult* _res_)
{
	gboolean result;
	ProtonPlusUtilsCacheManagerClearCacheData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static void
proton_plus_utils_cache_manager_clear_cache_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_)
{
	ProtonPlusUtilsCacheManagerClearCacheData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	proton_plus_utils_cache_manager_clear_cache_co (_data_);
}

static gboolean
proton_plus_utils_cache_manager_clear_cache_co (ProtonPlusUtilsCacheManagerClearCacheData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	while (TRUE) {
		if (!proton_plus_utils_cache_manager_clearing_cache) {
			break;
		}
		_data_->_state_ = 1;
		proton_plus_utils_cache_manager_wait_for_cache_state_change (proton_plus_utils_cache_manager_clear_cache_ready, _data_);
		return FALSE;
		_state_1:
		proton_plus_utils_cache_manager_wait_for_cache_state_change_finish (_data_->_res_);
	}
	proton_plus_utils_cache_manager_clearing_cache = TRUE;
	while (TRUE) {
		if (!(proton_plus_utils_cache_manager_active_cache_operations > ((guint) 0))) {
			break;
		}
		_data_->_state_ = 2;
		proton_plus_utils_cache_manager_wait_for_cache_state_change (proton_plus_utils_cache_manager_clear_cache_ready, _data_);
		return FALSE;
		_state_2:
		proton_plus_utils_cache_manager_wait_for_cache_state_change_finish (_data_->_res_);
	}
	_data_->success = TRUE;
	_data_->_tmp0_ = proton_plus_globals_CACHE_PATH;
	if (g_file_test (_data_->_tmp0_, G_FILE_TEST_IS_DIR)) {
		_data_->_tmp1_ = proton_plus_globals_CACHE_PATH;
		_data_->_state_ = 3;
		proton_plus_utils_filesystem_delete_directory (_data_->_tmp1_, proton_plus_utils_cache_manager_clear_cache_ready, _data_);
		return FALSE;
		_state_3:
		if (!proton_plus_utils_filesystem_delete_directory_finish (_data_->_res_)) {
			_data_->success = FALSE;
		}
	}
	if (_data_->success) {
		_data_->_tmp2_ = proton_plus_globals_CACHE_PATH;
		_data_->success = proton_plus_utils_filesystem_create_directory (_data_->_tmp2_);
	}
	proton_plus_utils_cache_manager_clearing_cache = FALSE;
	_data_->result = _data_->success;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

ProtonPlusUtilsCacheManager*
proton_plus_utils_cache_manager_construct (GType object_type)
{
	ProtonPlusUtilsCacheManager* self = NULL;
	self = (ProtonPlusUtilsCacheManager*) g_type_create_instance (object_type);
	return self;
}

ProtonPlusUtilsCacheManager*
proton_plus_utils_cache_manager_new (void)
{
	return proton_plus_utils_cache_manager_construct (PROTON_PLUS_UTILS_TYPE_CACHE_MANAGER);
}

static void
proton_plus_utils_value_cache_manager_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
proton_plus_utils_value_cache_manager_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		proton_plus_utils_cache_manager_unref (value->data[0].v_pointer);
	}
}

static void
proton_plus_utils_value_cache_manager_copy_value (const GValue* src_value,
                                                  GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = proton_plus_utils_cache_manager_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
proton_plus_utils_value_cache_manager_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
proton_plus_utils_value_cache_manager_collect_value (GValue* value,
                                                     guint n_collect_values,
                                                     GTypeCValue* collect_values,
                                                     guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		ProtonPlusUtilsCacheManager * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = proton_plus_utils_cache_manager_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
proton_plus_utils_value_cache_manager_lcopy_value (const GValue* value,
                                                   guint n_collect_values,
                                                   GTypeCValue* collect_values,
                                                   guint collect_flags)
{
	ProtonPlusUtilsCacheManager ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = proton_plus_utils_cache_manager_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
proton_plus_utils_param_spec_cache_manager (const gchar* name,
                                            const gchar* nick,
                                            const gchar* blurb,
                                            GType object_type,
                                            GParamFlags flags)
{
	ProtonPlusUtilsParamSpecCacheManager* spec;
	g_return_val_if_fail (g_type_is_a (object_type, PROTON_PLUS_UTILS_TYPE_CACHE_MANAGER), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
proton_plus_utils_value_get_cache_manager (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, PROTON_PLUS_UTILS_TYPE_CACHE_MANAGER), NULL);
	return value->data[0].v_pointer;
}

void
proton_plus_utils_value_set_cache_manager (GValue* value,
                                           gpointer v_object)
{
	ProtonPlusUtilsCacheManager * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, PROTON_PLUS_UTILS_TYPE_CACHE_MANAGER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, PROTON_PLUS_UTILS_TYPE_CACHE_MANAGER));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		proton_plus_utils_cache_manager_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		proton_plus_utils_cache_manager_unref (old);
	}
}

void
proton_plus_utils_value_take_cache_manager (GValue* value,
                                            gpointer v_object)
{
	ProtonPlusUtilsCacheManager * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, PROTON_PLUS_UTILS_TYPE_CACHE_MANAGER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, PROTON_PLUS_UTILS_TYPE_CACHE_MANAGER));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		proton_plus_utils_cache_manager_unref (old);
	}
}

static void
proton_plus_utils_cache_manager_class_init (ProtonPlusUtilsCacheManagerClass * klass,
                                            gpointer klass_data)
{
	proton_plus_utils_cache_manager_parent_class = g_type_class_peek_parent (klass);
	((ProtonPlusUtilsCacheManagerClass *) klass)->finalize = proton_plus_utils_cache_manager_finalize;
}

static void
proton_plus_utils_cache_manager_instance_init (ProtonPlusUtilsCacheManager * self,
                                               gpointer klass)
{
	self->ref_count = 1;
}

static void
proton_plus_utils_cache_manager_finalize (ProtonPlusUtilsCacheManager * obj)
{
	ProtonPlusUtilsCacheManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_UTILS_TYPE_CACHE_MANAGER, ProtonPlusUtilsCacheManager);
	g_signal_handlers_destroy (self);
}

static GType
proton_plus_utils_cache_manager_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { proton_plus_utils_value_cache_manager_init, proton_plus_utils_value_cache_manager_free_value, proton_plus_utils_value_cache_manager_copy_value, proton_plus_utils_value_cache_manager_peek_pointer, "p", proton_plus_utils_value_cache_manager_collect_value, "p", proton_plus_utils_value_cache_manager_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusUtilsCacheManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_utils_cache_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusUtilsCacheManager), 0, (GInstanceInitFunc) proton_plus_utils_cache_manager_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType proton_plus_utils_cache_manager_type_id;
	proton_plus_utils_cache_manager_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ProtonPlusUtilsCacheManager", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return proton_plus_utils_cache_manager_type_id;
}

GType
proton_plus_utils_cache_manager_get_type (void)
{
	static volatile gsize proton_plus_utils_cache_manager_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_cache_manager_type_id__once)) {
		GType proton_plus_utils_cache_manager_type_id;
		proton_plus_utils_cache_manager_type_id = proton_plus_utils_cache_manager_get_type_once ();
		g_once_init_leave (&proton_plus_utils_cache_manager_type_id__once, proton_plus_utils_cache_manager_type_id);
	}
	return proton_plus_utils_cache_manager_type_id__once;
}

gpointer
proton_plus_utils_cache_manager_ref (gpointer instance)
{
	ProtonPlusUtilsCacheManager * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
proton_plus_utils_cache_manager_unref (gpointer instance)
{
	ProtonPlusUtilsCacheManager * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		PROTON_PLUS_UTILS_CACHE_MANAGER_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

