mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-06-26 01:40:38 +00:00
Change GPrivate usage to GStaticPrivate, assuming it's more trustworthy
Original commit message from CVS: Change GPrivate usage to GStaticPrivate, assuming it's more trustworthy
This commit is contained in:
parent
c5ee2d3051
commit
f161e16a44
|
@ -71,7 +71,7 @@ struct _cothread_context
|
||||||
* (ie. private) for each thread. The key itself is shared among threads,
|
* (ie. private) for each thread. The key itself is shared among threads,
|
||||||
* so it only needs to be initialized once.
|
* so it only needs to be initialized once.
|
||||||
*/
|
*/
|
||||||
static GPrivate *_cothread_ctx_key;
|
static GStaticPrivate _cothread_ctx_key = G_STATIC_PRIVATE_INIT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This should only after context init, since we do checking.
|
* This should only after context init, since we do checking.
|
||||||
|
@ -81,7 +81,7 @@ cothread_get_current_context (void)
|
||||||
{
|
{
|
||||||
cothread_context *ctx;
|
cothread_context *ctx;
|
||||||
|
|
||||||
ctx = g_private_get (_cothread_ctx_key);
|
ctx = g_static_private_get (&_cothread_ctx_key);
|
||||||
g_assert(ctx);
|
g_assert(ctx);
|
||||||
|
|
||||||
#ifdef COTHREAD_PARANOID
|
#ifdef COTHREAD_PARANOID
|
||||||
|
@ -106,7 +106,7 @@ cothread_context_init (void)
|
||||||
|
|
||||||
/* if there already is a cotread context for this thread,
|
/* if there already is a cotread context for this thread,
|
||||||
* just return it */
|
* just return it */
|
||||||
ctx = g_private_get (_cothread_ctx_key);
|
ctx = g_static_private_get (&_cothread_ctx_key);
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
GST_INFO (GST_CAT_COTHREADS,
|
GST_INFO (GST_CAT_COTHREADS,
|
||||||
"returning private _cothread_ctx_key %p", ctx);
|
"returning private _cothread_ctx_key %p", ctx);
|
||||||
|
@ -126,17 +126,19 @@ cothread_context_init (void)
|
||||||
|
|
||||||
GST_INFO (GST_CAT_COTHREADS, "initializing cothreads");
|
GST_INFO (GST_CAT_COTHREADS, "initializing cothreads");
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* initialize the cothread key (for GThread space) if not done yet */
|
/* initialize the cothread key (for GThread space) if not done yet */
|
||||||
/* FIXME this should be done in cothread_init() */
|
/* FIXME this should be done in cothread_init() */
|
||||||
if (_cothread_ctx_key == NULL) {
|
if (_cothread_ctx_key == NULL) {
|
||||||
_cothread_ctx_key = g_private_new (NULL);
|
_cothread_ctx_key = g_private_new (NULL);
|
||||||
g_assert (_cothread_ctx_key);
|
g_assert (_cothread_ctx_key);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* set this thread's context pointer */
|
/* set this thread's context pointer */
|
||||||
GST_INFO (GST_CAT_COTHREADS, "setting private _cothread_ctx_key to %p",
|
GST_INFO (GST_CAT_COTHREADS, "setting private _cothread_ctx_key to %p",
|
||||||
ctx);
|
ctx);
|
||||||
g_private_set (_cothread_ctx_key, ctx);
|
g_static_private_set (&_cothread_ctx_key, ctx, NULL);
|
||||||
|
|
||||||
/* clear the cothread data */
|
/* clear the cothread data */
|
||||||
memset (ctx->cothreads, 0, sizeof (ctx->cothreads));
|
memset (ctx->cothreads, 0, sizeof (ctx->cothreads));
|
||||||
|
@ -195,7 +197,7 @@ cothread_context_free (cothread_context *ctx)
|
||||||
}
|
}
|
||||||
g_hash_table_destroy (ctx->data);
|
g_hash_table_destroy (ctx->data);
|
||||||
/* make sure we free the private key for cothread context */
|
/* make sure we free the private key for cothread context */
|
||||||
g_private_set (_cothread_ctx_key, NULL);
|
g_static_private_set (&_cothread_ctx_key, NULL, NULL);
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue