core: add source nullable parameter in _idle_add and _timeout_add APIs
This commit is contained in:
@@ -460,6 +460,7 @@ wp_core_is_connected (WpCore * self)
|
|||||||
/**
|
/**
|
||||||
* wp_core_idle_add:
|
* wp_core_idle_add:
|
||||||
* @self: the core
|
* @self: the core
|
||||||
|
* @source: (out) (optional): the source
|
||||||
* @function: (scope notified): the function to call
|
* @function: (scope notified): the function to call
|
||||||
* @data: (closure): data to pass to @function
|
* @data: (closure): data to pass to @function
|
||||||
* @destroy: (nullable): a function to destroy @data
|
* @destroy: (nullable): a function to destroy @data
|
||||||
@@ -468,26 +469,27 @@ wp_core_is_connected (WpCore * self)
|
|||||||
* one used by this core. This is essentially the same as g_idle_add_full(),
|
* one used by this core. This is essentially the same as g_idle_add_full(),
|
||||||
* but it adds the created #GSource on the #GMainContext used by this core
|
* but it adds the created #GSource on the #GMainContext used by this core
|
||||||
* instead of the default context.
|
* instead of the default context.
|
||||||
*
|
|
||||||
* Returns: the ID (greater than 0) of the event source
|
|
||||||
*/
|
*/
|
||||||
guint
|
void
|
||||||
wp_core_idle_add (WpCore * self, GSourceFunc function, gpointer data,
|
wp_core_idle_add (WpCore * self, GSource **source, GSourceFunc function,
|
||||||
GDestroyNotify destroy)
|
gpointer data, GDestroyNotify destroy)
|
||||||
{
|
{
|
||||||
g_autoptr (GSource) source = NULL;
|
g_autoptr (GSource) s = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (WP_IS_CORE (self), 0);
|
g_return_if_fail (WP_IS_CORE (self));
|
||||||
|
|
||||||
source = g_idle_source_new ();
|
s = g_idle_source_new ();
|
||||||
g_source_set_callback (source, function, data, destroy);
|
g_source_set_callback (s, function, data, destroy);
|
||||||
g_source_attach (source, self->context);
|
g_source_attach (s, self->context);
|
||||||
return g_source_get_id (source);
|
|
||||||
|
if (source)
|
||||||
|
*source = g_source_ref (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wp_core_timeout_add:
|
* wp_core_timeout_add:
|
||||||
* @self: the core
|
* @self: the core
|
||||||
|
* @source: (out) (optional): the source
|
||||||
* @timeout_ms: the timeout in milliseconds
|
* @timeout_ms: the timeout in milliseconds
|
||||||
* @function: (scope notified): the function to call
|
* @function: (scope notified): the function to call
|
||||||
* @data: (closure): data to pass to @function
|
* @data: (closure): data to pass to @function
|
||||||
@@ -500,21 +502,21 @@ wp_core_idle_add (WpCore * self, GSourceFunc function, gpointer data,
|
|||||||
* will be at the end of the first interval. This is essentially the same as
|
* will be at the end of the first interval. This is essentially the same as
|
||||||
* g_timeout_add_full(), but it adds the created #GSource on the #GMainContext
|
* g_timeout_add_full(), but it adds the created #GSource on the #GMainContext
|
||||||
* used by this core instead of the default context.
|
* used by this core instead of the default context.
|
||||||
*
|
|
||||||
* Returns: the ID (greater than 0) of the event source
|
|
||||||
*/
|
*/
|
||||||
guint
|
void
|
||||||
wp_core_timeout_add (WpCore * self, guint64 timeout_ms,
|
wp_core_timeout_add (WpCore * self, GSource **source, guint64 timeout_ms,
|
||||||
GSourceFunc function, gpointer data, GDestroyNotify destroy)
|
GSourceFunc function, gpointer data, GDestroyNotify destroy)
|
||||||
{
|
{
|
||||||
g_autoptr (GSource) source = NULL;
|
g_autoptr (GSource) s = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (WP_IS_CORE (self), 0);
|
g_return_if_fail (WP_IS_CORE (self));
|
||||||
|
|
||||||
source = g_timeout_source_new (timeout_ms);
|
s = g_timeout_source_new (timeout_ms);
|
||||||
g_source_set_callback (source, function, data, destroy);
|
g_source_set_callback (s, function, data, destroy);
|
||||||
g_source_attach (source, self->context);
|
g_source_attach (s, self->context);
|
||||||
return g_source_get_id (source);
|
|
||||||
|
if (source)
|
||||||
|
*source = g_source_ref (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -50,11 +50,11 @@ gboolean wp_core_is_connected (WpCore * self);
|
|||||||
/* Callback */
|
/* Callback */
|
||||||
|
|
||||||
WP_API
|
WP_API
|
||||||
guint wp_core_idle_add (WpCore * self, GSourceFunc function, gpointer data,
|
void wp_core_idle_add (WpCore * self, GSource **source, GSourceFunc function,
|
||||||
GDestroyNotify destroy);
|
gpointer data, GDestroyNotify destroy);
|
||||||
|
|
||||||
WP_API
|
WP_API
|
||||||
guint wp_core_timeout_add (WpCore * self, guint64 timeout_ms,
|
void wp_core_timeout_add (WpCore * self, GSource **source, guint64 timeout_ms,
|
||||||
GSourceFunc function, gpointer data, GDestroyNotify destroy);
|
GSourceFunc function, gpointer data, GDestroyNotify destroy);
|
||||||
|
|
||||||
WP_API
|
WP_API
|
||||||
|
@@ -171,7 +171,7 @@ wp_fake_endpoint_init_async (GAsyncInitable *initable, int io_priority,
|
|||||||
g_autoptr (WpCore) core = wp_base_endpoint_get_core (WP_BASE_ENDPOINT(self));
|
g_autoptr (WpCore) core = wp_base_endpoint_get_core (WP_BASE_ENDPOINT(self));
|
||||||
g_return_if_fail (core);
|
g_return_if_fail (core);
|
||||||
|
|
||||||
wp_core_idle_add (core, wp_fake_endpoint_finish_creation, self, NULL);
|
wp_core_idle_add (core, NULL, wp_fake_endpoint_finish_creation, self, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -113,7 +113,7 @@ wp_fake_endpoint_link_init_async (GAsyncInitable *initable, int io_priority,
|
|||||||
g_autoptr (WpCore) core = g_weak_ref_get (&self->core);
|
g_autoptr (WpCore) core = g_weak_ref_get (&self->core);
|
||||||
g_return_if_fail (core);
|
g_return_if_fail (core);
|
||||||
|
|
||||||
wp_core_idle_add (core, wp_fake_endpoint_link_finish_creation, self, NULL);
|
wp_core_idle_add (core, NULL, wp_fake_endpoint_link_finish_creation, self, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user