}
/* ---------------------------------------------------------------------------------------------------- */
-static void maybe_write_next_message (GDBusWorker *worker);
+static void continue_writing (GDBusWorker *worker);
typedef struct
{
g_mutex_unlock (&data->worker->write_lock);
/* OK, cool, finally kick off the next write */
- maybe_write_next_message (data->worker);
+ continue_writing (data->worker);
_g_dbus_worker_unref (data->worker);
g_free (data);
else
{
/* kick off the next write! */
- maybe_write_next_message (worker);
+ continue_writing (worker);
}
}
* output_pending must be PENDING_NONE on entry
*/
static void
-maybe_write_next_message (GDBusWorker *worker)
+continue_writing (GDBusWorker *worker)
{
MessageToWriteData *data;
* output_pending may be anything
*/
static gboolean
-write_message_in_idle_cb (gpointer user_data)
+continue_writing_in_idle_cb (gpointer user_data)
{
GDBusWorker *worker = user_data;
* without holding the lock: no other thread ever modifies it.
*/
if (worker->output_pending == PENDING_NONE)
- maybe_write_next_message (worker);
+ continue_writing (worker);
return FALSE;
}
*
* Can be called from any thread
*
- * write_lock is not held on entry
+ * write_lock is held on entry
* output_pending may be anything
*/
static void
-schedule_write_in_worker_thread (GDBusWorker *worker,
- MessageToWriteData *write_data,
- CloseData *close_data)
+schedule_writing_unlocked (GDBusWorker *worker,
+ MessageToWriteData *write_data,
+ CloseData *close_data)
{
- g_mutex_lock (&worker->write_lock);
-
if (write_data != NULL)
g_queue_push_tail (worker->write_queue, write_data);
idle_source = g_idle_source_new ();
g_source_set_priority (idle_source, G_PRIORITY_DEFAULT);
g_source_set_callback (idle_source,
- write_message_in_idle_cb,
+ continue_writing_in_idle_cb,
_g_dbus_worker_ref (worker),
(GDestroyNotify) _g_dbus_worker_unref);
g_source_attach (idle_source, worker->shared_thread_data->context);
g_source_unref (idle_source);
}
-
- g_mutex_unlock (&worker->write_lock);
}
/* ---------------------------------------------------------------------------------------------------- */
data->blob = blob; /* steal! */
data->blob_size = blob_len;
- schedule_write_in_worker_thread (worker, data, NULL);
+ g_mutex_lock (&worker->write_lock);
+ schedule_writing_unlocked (worker, data, NULL);
+ g_mutex_unlock (&worker->write_lock);
}
/* ---------------------------------------------------------------------------------------------------- */
* It'll be set before the actual close happens.
*/
g_cancellable_cancel (worker->cancellable);
- schedule_write_in_worker_thread (worker, NULL, close_data);
+ g_mutex_lock (&worker->write_lock);
+ schedule_writing_unlocked (worker, NULL, close_data);
+ g_mutex_unlock (&worker->write_lock);
}
/* This can be called from any thread - frees worker. Note that