Deprecate g_{mutex,cond}_{new,free}()

Now that we have _init() and _clear(), these old calls are no longer
useful.

https://bugzilla.gnome.org/show_bug.cgi?id=660739
This commit is contained in:
Ryan Lortie 2011-10-04 19:09:43 -04:00
parent 26a6b3c6ff
commit 69c0b4440e
4 changed files with 88 additions and 76 deletions

View File

@ -1406,5 +1406,89 @@ g_static_private_cleanup (GRealThread *thread)
}
}
/* GMutex {{{1 ------------------------------------------------------ */
/**
* g_mutex_new:
*
* Allocates and initializes a new #GMutex.
*
* Returns: a newly allocated #GMutex. Use g_mutex_free() to free
*
* Deprecated:3.32:GMutex can now be statically allocated, or embedded
* in structures and initialised with g_mutex_init().
*/
GMutex *
g_mutex_new (void)
{
GMutex *mutex;
mutex = g_slice_new (GMutex);
g_mutex_init (mutex);
return mutex;
}
/**
* g_mutex_free:
* @mutex: a #GMutex
*
* Destroys a @mutex that has been created with g_mutex_new().
*
* Calling g_mutex_free() on a locked mutex may result
* in undefined behaviour.
*
* Deprecated:3.32:GMutex can now be statically allocated, or embedded
* in structures and initialised with g_mutex_init().
*/
void
g_mutex_free (GMutex *mutex)
{
g_mutex_clear (mutex);
g_slice_free (GMutex, mutex);
}
/* GCond {{{1 ------------------------------------------------------ */
/**
* g_cond_new:
*
* Allocates and initializes a new #GCond.
*
* Returns: a newly allocated #GCond. Free with g_cond_free()
*
* Deprecated:3.32:GCond can now be statically allocated, or embedded
* in structures and initialised with g_cond_init().
*/
GCond *
g_cond_new (void)
{
GCond *cond;
cond = g_slice_new (GCond);
g_cond_init (cond);
return cond;
}
/**
* g_cond_free:
* @cond: a #GCond
*
* Destroys a #GCond that has been created with g_cond_new().
*
* Calling g_cond_free() for a #GCond on which threads are
* blocking leads to undefined behaviour.
*
* Deprecated:3.32:GCond can now be statically allocated, or embedded
* in structures and initialised with g_cond_init().
*/
void
g_cond_free (GCond *cond)
{
g_cond_clear (cond);
g_slice_free (GCond, cond);
}
/* {{{1 Epilogue */
/* vim: set foldmethod=marker: */

View File

@ -214,6 +214,10 @@ GLIB_VAR gboolean g_threads_got_initialized;
GMutex* g_static_mutex_get_mutex_impl (GMutex **mutex);
GMutex * g_mutex_new (void);
void g_mutex_free (GMutex *mutex);
GCond * g_cond_new (void);
void g_cond_free (GCond *cond);
G_END_DECLS

View File

@ -1022,77 +1022,5 @@ g_thread_self (void)
return (GThread*)thread;
}
/* GMutex {{{1 ------------------------------------------------------ */
/**
* g_mutex_new:
*
* Allocates and initializes a new #GMutex.
*
* Returns: a newly allocated #GMutex. Use g_mutex_free() to free
*/
GMutex *
g_mutex_new (void)
{
GMutex *mutex;
mutex = g_slice_new (GMutex);
g_mutex_init (mutex);
return mutex;
}
/**
* g_mutex_free:
* @mutex: a #GMutex
*
* Destroys a @mutex that has been created with g_mutex_new().
*
* Calling g_mutex_free() on a locked mutex may result
* in undefined behaviour.
*/
void
g_mutex_free (GMutex *mutex)
{
g_mutex_clear (mutex);
g_slice_free (GMutex, mutex);
}
/* GCond {{{1 ------------------------------------------------------ */
/**
* g_cond_new:
*
* Allocates and initializes a new #GCond.
*
* Returns: a newly allocated #GCond. Free with g_cond_free()
*/
GCond *
g_cond_new (void)
{
GCond *cond;
cond = g_slice_new (GCond);
g_cond_init (cond);
return cond;
}
/**
* g_cond_free:
* @cond: a #GCond
*
* Destroys a #GCond that has been created with g_cond_new().
*
* Calling g_cond_free() for a #GCond on which threads are
* blocking leads to undefined behaviour.
*/
void
g_cond_free (GCond *cond)
{
g_cond_clear (cond);
g_slice_free (GCond, cond);
}
/* Epilogue {{{1 */
/* vim: set foldmethod=marker: */

View File

@ -198,8 +198,6 @@ void g_once_init_leave (volatile void *location,
#endif /* !G_DEBUG_LOCKS */
GMutex * g_mutex_new (void);
void g_mutex_free (GMutex *mutex);
void g_mutex_init (GMutex *mutex);
void g_mutex_clear (GMutex *mutex);
@ -222,8 +220,6 @@ void g_rec_mutex_lock (GRecMut
gboolean g_rec_mutex_trylock (GRecMutex *rec_mutex);
void g_rec_mutex_unlock (GRecMutex *rec_mutex);
GCond * g_cond_new (void);
void g_cond_free (GCond *cond);
void g_cond_init (GCond *cond);
void g_cond_clear (GCond *cond);