core: new `MMAsyncMethod' boxed type

Helps to bundle the async method implementation in a property.
This commit is contained in:
Aleksander Morgado
2012-07-11 08:26:38 +02:00
parent f5fdf946c9
commit 79abe00221
2 changed files with 44 additions and 0 deletions

View File

@@ -170,3 +170,40 @@ mm_pointer_array_get_type (void)
return g_define_type_id__volatile;
}
static void
async_method_free (MMAsyncMethod *method)
{
g_slice_free (MMAsyncMethod, method);
}
static MMAsyncMethod *
async_method_copy (MMAsyncMethod *original)
{
MMAsyncMethod *copy;
if (!original)
return NULL;
copy = g_slice_new (MMAsyncMethod);
copy->async = original->async;
copy->finish = original->finish;
return copy;
}
GType
mm_async_method_get_type (void)
{
static volatile gsize g_define_type_id__volatile = 0;
if (g_once_init_enter (&g_define_type_id__volatile)) {
GType g_define_type_id =
g_boxed_type_register_static (g_intern_static_string ("MMAsyncMethod"),
(GBoxedCopyFunc) async_method_copy,
(GBoxedFreeFunc) async_method_free);
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
}
return g_define_type_id__volatile;
}

View File

@@ -34,6 +34,13 @@ GType mm_str_pair_array_get_type (void) G_GNUC_CONST;
GType mm_pointer_array_get_type (void) G_GNUC_CONST;
#define MM_TYPE_POINTER_ARRAY (mm_pointer_array_get_type ())
typedef struct {
GCallback async;
GCallback finish;
} MMAsyncMethod;
GType mm_async_method_get_type (void) G_GNUC_CONST;
#define MM_TYPE_ASYNC_METHOD (mm_async_method_get_type ())
G_END_DECLS
#endif /* __MM_PRIVATE_BOXED_TYPES_H__ */