#endif
#ifndef HAVE_FUTEX
-static GStaticMutex g_futex_mutex = G_STATIC_MUTEX_INIT;
+static GMutex g_futex_mutex = G_MUTEX_INIT;
static GSList *g_futex_address_list = NULL;
#endif
g_futex_wait (const volatile gint *address,
gint value)
{
- g_static_mutex_lock (&g_futex_mutex);
+ g_mutex_lock (&g_futex_mutex);
if G_LIKELY (g_atomic_int_get (address) == value)
{
WaitAddress *waiter;
}
waiter->ref_count++;
- g_cond_wait (waiter->wait_queue, g_static_mutex_get_mutex (&g_futex_mutex));
+ g_cond_wait (waiter->wait_queue, &g_futex_mutex);
if (!--waiter->ref_count)
{
g_slice_free (WaitAddress, waiter);
}
}
- g_static_mutex_unlock (&g_futex_mutex);
+ g_mutex_unlock (&g_futex_mutex);
}
static void
* 2) need to -stay- locked until the end to ensure a wake()
* in another thread doesn't cause 'waiter' to stop existing
*/
- g_static_mutex_lock (&g_futex_mutex);
+ g_mutex_lock (&g_futex_mutex);
if ((waiter = g_futex_find_address (address)))
g_cond_signal (waiter->wait_queue);
- g_static_mutex_unlock (&g_futex_mutex);
+ g_mutex_unlock (&g_futex_mutex);
}
#endif
/* The following lock is used for both the list of sources
* and the list of poll records
*/
- GStaticMutex mutex;
+ GMutex mutex;
GCond *cond;
GThread *owner;
guint owner_count;
GSource *parent_source;
};
-#define LOCK_CONTEXT(context) g_static_mutex_lock (&context->mutex)
-#define UNLOCK_CONTEXT(context) g_static_mutex_unlock (&context->mutex)
+#define LOCK_CONTEXT(context) g_mutex_lock (&context->mutex)
+#define UNLOCK_CONTEXT(context) g_mutex_unlock (&context->mutex)
#define G_THREAD_SELF g_thread_self ()
#define SOURCE_DESTROYED(source) (((source)->flags & G_HOOK_FLAG_ACTIVE) == 0)
source = next;
}
- g_static_mutex_free (&context->mutex);
+ g_mutex_clear (&context->mutex);
g_ptr_array_free (context->pending_dispatches, TRUE);
g_free (context->cached_poll_array);
context = g_new0 (GMainContext, 1);
- g_static_mutex_init (&context->mutex);
+ g_mutex_init (&context->mutex);
context->owner = NULL;
context->waiters = NULL;
if (context->waiters)
{
GMainWaiter *waiter = context->waiters->data;
- gboolean loop_internal_waiter =
- (waiter->mutex == g_static_mutex_get_mutex (&context->mutex));
+ gboolean loop_internal_waiter = (waiter->mutex == &context->mutex);
context->waiters = g_slist_delete_link (context->waiters,
context->waiters);
if (!loop_internal_waiter)
if (context == NULL)
context = g_main_context_default ();
- loop_internal_waiter = (mutex == g_static_mutex_get_mutex (&context->mutex));
+ loop_internal_waiter = (mutex == &context->mutex);
if (!loop_internal_waiter)
LOCK_CONTEXT (context);
got_ownership = g_main_context_wait (context,
context->cond,
- g_static_mutex_get_mutex (&context->mutex));
+ &context->mutex);
if (!got_ownership)
return FALSE;
while (loop->is_running && !got_ownership)
got_ownership = g_main_context_wait (loop->context,
loop->context->cond,
- g_static_mutex_get_mutex (&loop->context->mutex));
+ &loop->context->mutex);
if (!loop->is_running)
{