mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-22 00:48:53 +02:00
Added functions g_static_rec_mutex_init, g_static_rec_mutex_free,
2001-02-13 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * gthread.c, gthread.h: Added functions g_static_rec_mutex_init, g_static_rec_mutex_free, g_static_private_init, g_static_private_free, g_static_rw_lock_init to allow the usage of all those types dynamically. (g_static_rw_lock_free already existed). Aditionally freed static_private indeces are reused now. Untill now the array would just grow if you would use more and more static_private. That required adding a slist of all running threads, which could potentially be of good use later. It is not exported however. Renamed a LOCK and small indentation fixes. * tests/thread-test.c: Test the new static_private index freing and reusing feature.
This commit is contained in:
committed by
Sebastian Wilhelmi
parent
cc0f6f0232
commit
41e2001d85
31
gthread.h
31
gthread.h
@@ -46,8 +46,8 @@ G_BEGIN_DECLS
|
||||
/* GLib Thread support
|
||||
*/
|
||||
|
||||
extern GQuark g_thread_error_quark();
|
||||
#define G_THREAD_ERROR g_thread_error_quark()
|
||||
extern GQuark g_thread_error_quark (void);
|
||||
#define G_THREAD_ERROR g_thread_error_quark ()
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -235,16 +235,18 @@ struct _GStaticPrivate
|
||||
guint index;
|
||||
};
|
||||
#define G_STATIC_PRIVATE_INIT { 0 }
|
||||
gpointer g_static_private_get (GStaticPrivate *private_key);
|
||||
void g_static_private_set (GStaticPrivate *private_key,
|
||||
gpointer data,
|
||||
GDestroyNotify notify);
|
||||
gpointer g_static_private_get_for_thread (GStaticPrivate *private_key,
|
||||
GThread *thread);
|
||||
void g_static_private_set_for_thread (GStaticPrivate *private_key,
|
||||
GThread *thread,
|
||||
gpointer data,
|
||||
GDestroyNotify notify);
|
||||
void g_static_private_init (GStaticPrivate *private_key);
|
||||
gpointer g_static_private_get (GStaticPrivate *private_key);
|
||||
void g_static_private_set (GStaticPrivate *private_key,
|
||||
gpointer data,
|
||||
GDestroyNotify notify);
|
||||
gpointer g_static_private_get_for_thread (GStaticPrivate *private_key,
|
||||
GThread *thread);
|
||||
void g_static_private_set_for_thread (GStaticPrivate *private_key,
|
||||
GThread *thread,
|
||||
gpointer data,
|
||||
GDestroyNotify notify);
|
||||
void g_static_private_free (GStaticPrivate *private_key);
|
||||
|
||||
typedef struct _GStaticRecMutex GStaticRecMutex;
|
||||
struct _GStaticRecMutex
|
||||
@@ -255,12 +257,14 @@ struct _GStaticRecMutex
|
||||
};
|
||||
|
||||
#define G_STATIC_REC_MUTEX_INIT { G_STATIC_MUTEX_INIT }
|
||||
void g_static_rec_mutex_init (GStaticRecMutex *mutex);
|
||||
void g_static_rec_mutex_lock (GStaticRecMutex *mutex);
|
||||
gboolean g_static_rec_mutex_trylock (GStaticRecMutex *mutex);
|
||||
void g_static_rec_mutex_unlock (GStaticRecMutex *mutex);
|
||||
void g_static_rec_mutex_lock_full (GStaticRecMutex *mutex,
|
||||
guint depth);
|
||||
guint g_static_rec_mutex_unlock_full (GStaticRecMutex *mutex);
|
||||
void g_static_rec_mutex_free (GStaticRecMutex *mutex);
|
||||
|
||||
typedef struct _GStaticRWLock GStaticRWLock;
|
||||
struct _GStaticRWLock
|
||||
@@ -275,13 +279,14 @@ struct _GStaticRWLock
|
||||
|
||||
#define G_STATIC_RW_LOCK_INIT { G_STATIC_MUTEX_INIT, NULL, NULL, 0, FALSE, FALSE }
|
||||
|
||||
void g_static_rw_lock_init (GStaticRWLock* lock);
|
||||
void g_static_rw_lock_reader_lock (GStaticRWLock* lock);
|
||||
gboolean g_static_rw_lock_reader_trylock (GStaticRWLock* lock);
|
||||
void g_static_rw_lock_reader_unlock (GStaticRWLock* lock);
|
||||
void g_static_rw_lock_writer_lock (GStaticRWLock* lock);
|
||||
gboolean g_static_rw_lock_writer_trylock (GStaticRWLock* lock);
|
||||
void g_static_rw_lock_writer_unlock (GStaticRWLock* lock);
|
||||
void g_static_rw_lock_free (GStaticRWLock* lock);
|
||||
void g_static_rw_lock_free (GStaticRWLock* lock);
|
||||
|
||||
/* these are some convenience macros that expand to nothing if GLib
|
||||
* was configured with --disable-threads. for using StaticMutexes,
|
||||
|
Reference in New Issue
Block a user