mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 11:26:16 +01:00
Merge branch '903-deprecate-main-context-wait' into 'master'
gmain: Officially deprecate g_main_context_wait() Closes #903 See merge request GNOME/glib!139
This commit is contained in:
commit
0ea541171d
74
glib/gmain.c
74
glib/gmain.c
@ -3307,23 +3307,8 @@ g_main_context_release (GMainContext *context)
|
||||
UNLOCK_CONTEXT (context);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_main_context_wait:
|
||||
* @context: a #GMainContext
|
||||
* @cond: a condition variable
|
||||
* @mutex: a mutex, currently held
|
||||
*
|
||||
* Tries to become the owner of the specified context,
|
||||
* as with g_main_context_acquire(). But if another thread
|
||||
* is the owner, atomically drop @mutex and wait on @cond until
|
||||
* that owner releases ownership or until @cond is signaled, then
|
||||
* try again (once) to become the owner.
|
||||
*
|
||||
* Returns: %TRUE if the operation succeeded, and
|
||||
* this thread is now the owner of @context.
|
||||
**/
|
||||
gboolean
|
||||
g_main_context_wait (GMainContext *context,
|
||||
static gboolean
|
||||
g_main_context_wait_internal (GMainContext *context,
|
||||
GCond *cond,
|
||||
GMutex *mutex)
|
||||
{
|
||||
@ -3334,18 +3319,6 @@ g_main_context_wait (GMainContext *context,
|
||||
if (context == NULL)
|
||||
context = g_main_context_default ();
|
||||
|
||||
if G_UNLIKELY (cond != &context->cond || mutex != &context->mutex)
|
||||
{
|
||||
static gboolean warned;
|
||||
|
||||
if (!warned)
|
||||
{
|
||||
g_critical ("WARNING!! g_main_context_wait() will be removed in a future release. "
|
||||
"If you see this message, please file a bug immediately.");
|
||||
warned = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
loop_internal_waiter = (mutex == &context->mutex);
|
||||
|
||||
if (!loop_internal_waiter)
|
||||
@ -3387,6 +3360,45 @@ g_main_context_wait (GMainContext *context,
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_main_context_wait:
|
||||
* @context: a #GMainContext
|
||||
* @cond: a condition variable
|
||||
* @mutex: a mutex, currently held
|
||||
*
|
||||
* Tries to become the owner of the specified context,
|
||||
* as with g_main_context_acquire(). But if another thread
|
||||
* is the owner, atomically drop @mutex and wait on @cond until
|
||||
* that owner releases ownership or until @cond is signaled, then
|
||||
* try again (once) to become the owner.
|
||||
*
|
||||
* Returns: %TRUE if the operation succeeded, and
|
||||
* this thread is now the owner of @context.
|
||||
* Deprecated: 2.58: Use g_main_context_is_owner() and separate locking instead.
|
||||
*/
|
||||
gboolean
|
||||
g_main_context_wait (GMainContext *context,
|
||||
GCond *cond,
|
||||
GMutex *mutex)
|
||||
{
|
||||
if (context == NULL)
|
||||
context = g_main_context_default ();
|
||||
|
||||
if (G_UNLIKELY (cond != &context->cond || mutex != &context->mutex))
|
||||
{
|
||||
static gboolean warned;
|
||||
|
||||
if (!warned)
|
||||
{
|
||||
g_critical ("WARNING!! g_main_context_wait() will be removed in a future release. "
|
||||
"If you see this message, please file a bug immediately.");
|
||||
warned = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return g_main_context_wait_internal (context, cond, mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_main_context_prepare:
|
||||
* @context: a #GMainContext
|
||||
@ -3864,7 +3876,7 @@ g_main_context_iterate (GMainContext *context,
|
||||
if (!block)
|
||||
return FALSE;
|
||||
|
||||
got_ownership = g_main_context_wait (context,
|
||||
got_ownership = g_main_context_wait_internal (context,
|
||||
&context->cond,
|
||||
&context->mutex);
|
||||
|
||||
@ -4073,7 +4085,7 @@ g_main_loop_run (GMainLoop *loop)
|
||||
loop->is_running = TRUE;
|
||||
|
||||
while (loop->is_running && !got_ownership)
|
||||
got_ownership = g_main_context_wait (loop->context,
|
||||
got_ownership = g_main_context_wait_internal (loop->context,
|
||||
&loop->context->cond,
|
||||
&loop->context->mutex);
|
||||
|
||||
|
@ -376,7 +376,7 @@ GLIB_AVAILABLE_IN_ALL
|
||||
void g_main_context_release (GMainContext *context);
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
gboolean g_main_context_is_owner (GMainContext *context);
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
GLIB_DEPRECATED_IN_2_58_FOR(g_main_context_is_owner)
|
||||
gboolean g_main_context_wait (GMainContext *context,
|
||||
GCond *cond,
|
||||
GMutex *mutex);
|
||||
|
Loading…
Reference in New Issue
Block a user