[glib-networking/mcatanzaro/tls-thread: 18/19] progress
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/mcatanzaro/tls-thread: 18/19] progress
- Date: Sat, 10 Aug 2019 00:44:08 +0000 (UTC)
commit 3b69adf4b91cff9b425ae732a4f71862cb62c0a1
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Fri Aug 9 19:16:01 2019 -0500
progress
tls/base/gtlsthread.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/tls/base/gtlsthread.c b/tls/base/gtlsthread.c
index 3733322..84891f5 100644
--- a/tls/base/gtlsthread.c
+++ b/tls/base/gtlsthread.c
@@ -210,8 +210,9 @@ typedef struct {
GAsyncQueue *queue;
} GTlsOpQueueSource;
-typedef gboolean (*GTlsOpQueueSourceFunc) (GAsyncQueue *queue,
- GMainLoop *main_loop);
+typedef gboolean (*GTlsOpQueueSourceFunc) (GAsyncQueue *queue,
+ GTlsThreadOperation *op,
+ GMainLoop *main_loop);
static gboolean
queue_has_pending_op (GAsyncQueue *queue)
@@ -242,8 +243,10 @@ tls_op_queue_source_prepare (GSource *source,
ready = queue_has_pending_op (op_source->queue);
- /* Why is it safe to use -1 as the timeout here? Because
- * g_main_context_wakeup() will be called when pushing ops onto the queue!
+ /* If we are ready to dispatch, timeout should be 0 to ensure poll() returns
+ * immediately. Otherwise, we are in no hurry and can wait "forever." If
+ * a new op is pushed onto the queue, the code performing the push is
+ * responsible for calling g_main_context_wakeup() to end the wait.
*/
*timeout = ready ? 0 : -1;
@@ -266,6 +269,7 @@ tls_op_queue_source_dispatch (GSource *source,
GTlsOpQueueSource *op_source = (GTlsOpQueueSource *)source;
return ((GTlsOpQueueSourceFunc)callback) (op_source->queue,
+ NULL, /* no delayed source */
user_data);
}
@@ -284,7 +288,7 @@ tls_op_queue_source_closure_callback (GAsyncQueue *queue,
{
GClosure *closure = data;
- GValue param[2] = { G_VALUE_INIT, G_VALUE_INIT };
+ GValue param[3] = { G_VALUE_INIT, G_VALUE_INIT, G_VALUE_INIT };
GValue result_value = G_VALUE_INIT;
gboolean result;
@@ -292,15 +296,18 @@ tls_op_queue_source_closure_callback (GAsyncQueue *queue,
g_value_init (¶m[0], G_TYPE_POINTER);
g_value_set_pointer (¶m[0], queue);
- g_value_init (¶m[1], G_TYPE_MAIN_LOOP);
- g_value_set_pointer (¶m[1], main_loop);
+ g_value_init (¶m[1], G_TYPE_POINTER);
+ g_value_set_pointer (¶m[1], NULL);
+ g_value_init (¶m[2], G_TYPE_MAIN_LOOP);
+ g_value_set_pointer (¶m[2], main_loop);
- g_closure_invoke (closure, &result_value, 2, param, NULL);
+ g_closure_invoke (closure, &result_value, 3, param, NULL);
result = g_value_get_boolean (&result_value);
g_value_unset (&result_value);
g_value_unset (¶m[0]);
g_value_unset (¶m[1]);
+ g_value_unset (¶m[2]);
return result;
}
@@ -424,9 +431,6 @@ process_op (GAsyncQueue *queue,
}
else
{
- /* We could use normal pop() here, but try_pop() allows us to assert that
- * we never block.
- */
op = g_async_queue_try_pop (queue);
g_assert (op);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]