</parameter>
</parameters>
</function>
+ <function name="test_callback_async" c:identifier="test_callback_async">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="callback"
+ transfer-ownership="none"
+ scope="async"
+ closure="1">
+ <type name="TestCallbackUserData" c:type="TestCallbackUserData"/>
+ </parameter>
+ <parameter name="user_data" transfer-ownership="none">
+ <type name="any" c:type="gpointer"/>
+ </parameter>
+ </parameters>
+ </function>
<function name="test_callback_destroy_notify"
c:identifier="test_callback_destroy_notify"
doc="Notified - callback persists until a DestroyNotify delegate
</parameter>
</parameters>
</function>
+ <function name="test_callback_thaw_async"
+ c:identifier="test_callback_thaw_async">
+ <return-value transfer-ownership="none">
+ <type name="int" c:type="int"/>
+ </return-value>
+ </function>
<function name="test_callback_thaw_notifications"
c:identifier="test_callback_thaw_notifications"
doc="Invokes all callbacks installed by #test_callback_destroy_notify(),
retval = callback(user_data);
- info = g_new(CallbackInfo, 1);
+ info = g_slice_new(CallbackInfo);
info->callback = callback;
info->notify = notify;
info->user_data = user_data;
for (node = notified_callbacks; node != NULL; node = node->next)
{
- CallbackInfo *info = (CallbackInfo *)node->data;
+ CallbackInfo *info = node->data;
retval += info->callback (info->user_data);
if (info->notify)
info->notify (info->user_data);
- g_free (info);
+ g_slice_free (CallbackInfo, info);
}
g_slist_free (notified_callbacks);
return retval;
}
+static GSList *async_callbacks = NULL;
+
+/**
+ * test_callback_async:
+ * @callback: (scope async):
+ *
+ **/
+void
+test_callback_async (TestCallbackUserData callback,
+ gpointer user_data)
+{
+ CallbackInfo *info;
+
+ info = g_slice_new(CallbackInfo);
+ info->callback = callback;
+ info->user_data = user_data;
+
+ async_callbacks = g_slist_prepend(async_callbacks, info);
+}
+
+/**
+ * test_callback_thaw_async:
+ */
+int
+test_callback_thaw_async (void)
+{
+ int retval = 0;
+ GSList *node;
+
+ for (node = async_callbacks; node != NULL; node = node->next)
+ {
+ CallbackInfo *info = node->data;
+ retval = info->callback (info->user_data);
+ g_slice_free (CallbackInfo, info);
+ }
+
+ g_slist_free (async_callbacks);
+ async_callbacks = NULL;
+ return retval;
+}
+
/**
* test_callback_infinite:
* @callback: (scope infinite):
gpointer user_data,
GDestroyNotify notify);
int test_callback_thaw_notifications (void);
+
+void test_callback_async (TestCallbackUserData callback, gpointer user_data);
+int test_callback_thaw_async (void);
+
int test_callback_infinite (TestCallbackUserData callback,
gpointer user_data);