gthread.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /* GLIB - Library of useful routines for C programming
  2. * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /*
  18. * Modified by the GLib Team and others 1997-2000. See the AUTHORS
  19. * file for a list of people on the GLib Team. See the ChangeLog
  20. * files for a list of changes. These files are distributed with
  21. * GLib at ftp://ftp.gtk.org/pub/gtk/.
  22. */
  23. #ifndef __G_DEPRECATED_THREAD_H__
  24. #define __G_DEPRECATED_THREAD_H__
  25. #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
  26. #error "Only <glib.h> can be included directly."
  27. #endif
  28. #include <glib/gthread.h>
  29. G_BEGIN_DECLS
  30. G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  31. typedef enum
  32. {
  33. G_THREAD_PRIORITY_LOW,
  34. G_THREAD_PRIORITY_NORMAL,
  35. G_THREAD_PRIORITY_HIGH,
  36. G_THREAD_PRIORITY_URGENT
  37. } GThreadPriority GLIB_DEPRECATED_TYPE_IN_2_32;
  38. struct _GThread
  39. {
  40. /*< private >*/
  41. GThreadFunc func;
  42. gpointer data;
  43. gboolean joinable;
  44. GThreadPriority priority;
  45. };
  46. typedef struct _GThreadFunctions GThreadFunctions GLIB_DEPRECATED_TYPE_IN_2_32;
  47. struct _GThreadFunctions
  48. {
  49. GMutex* (*mutex_new) (void);
  50. void (*mutex_lock) (GMutex *mutex);
  51. gboolean (*mutex_trylock) (GMutex *mutex);
  52. void (*mutex_unlock) (GMutex *mutex);
  53. void (*mutex_free) (GMutex *mutex);
  54. GCond* (*cond_new) (void);
  55. void (*cond_signal) (GCond *cond);
  56. void (*cond_broadcast) (GCond *cond);
  57. void (*cond_wait) (GCond *cond,
  58. GMutex *mutex);
  59. gboolean (*cond_timed_wait) (GCond *cond,
  60. GMutex *mutex,
  61. GTimeVal *end_time);
  62. void (*cond_free) (GCond *cond);
  63. GPrivate* (*private_new) (GDestroyNotify destructor);
  64. gpointer (*private_get) (GPrivate *private_key);
  65. void (*private_set) (GPrivate *private_key,
  66. gpointer data);
  67. void (*thread_create) (GThreadFunc func,
  68. gpointer data,
  69. gulong stack_size,
  70. gboolean joinable,
  71. gboolean bound,
  72. GThreadPriority priority,
  73. gpointer thread,
  74. GError **error);
  75. void (*thread_yield) (void);
  76. void (*thread_join) (gpointer thread);
  77. void (*thread_exit) (void);
  78. void (*thread_set_priority)(gpointer thread,
  79. GThreadPriority priority);
  80. void (*thread_self) (gpointer thread);
  81. gboolean (*thread_equal) (gpointer thread1,
  82. gpointer thread2);
  83. } GLIB_DEPRECATED_TYPE_IN_2_32;
  84. GLIB_VAR GThreadFunctions g_thread_functions_for_glib_use;
  85. GLIB_VAR gboolean g_thread_use_default_impl;
  86. GLIB_VAR guint64 (*g_thread_gettime) (void);
  87. GLIB_DEPRECATED_IN_2_32_FOR(g_thread_new)
  88. GThread *g_thread_create (GThreadFunc func,
  89. gpointer data,
  90. gboolean joinable,
  91. GError **error);
  92. GLIB_DEPRECATED_IN_2_32_FOR(g_thread_new)
  93. GThread *g_thread_create_full (GThreadFunc func,
  94. gpointer data,
  95. gulong stack_size,
  96. gboolean joinable,
  97. gboolean bound,
  98. GThreadPriority priority,
  99. GError **error);
  100. GLIB_DEPRECATED_IN_2_32
  101. void g_thread_set_priority (GThread *thread,
  102. GThreadPriority priority);
  103. GLIB_DEPRECATED_IN_2_32
  104. void g_thread_foreach (GFunc thread_func,
  105. gpointer user_data);
  106. #ifndef G_OS_WIN32
  107. #include <sys/types.h>
  108. #include <pthread.h>
  109. #endif
  110. #define g_static_mutex_get_mutex g_static_mutex_get_mutex_impl GLIB_DEPRECATED_MACRO_IN_2_32
  111. #define G_STATIC_MUTEX_INIT { NULL } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_init)
  112. typedef struct
  113. {
  114. GMutex *mutex;
  115. #ifndef G_OS_WIN32
  116. /* only for ABI compatibility reasons */
  117. pthread_mutex_t unused;
  118. #endif
  119. } GStaticMutex GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GMutex);
  120. #define g_static_mutex_lock(mutex) \
  121. g_mutex_lock (g_static_mutex_get_mutex (mutex)) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_lock)
  122. #define g_static_mutex_trylock(mutex) \
  123. g_mutex_trylock (g_static_mutex_get_mutex (mutex)) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_trylock)
  124. #define g_static_mutex_unlock(mutex) \
  125. g_mutex_unlock (g_static_mutex_get_mutex (mutex)) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_unlock)
  126. GLIB_DEPRECATED_IN_2_32_FOR(g_mutex_init)
  127. void g_static_mutex_init (GStaticMutex *mutex);
  128. GLIB_DEPRECATED_IN_2_32_FOR(g_mutex_clear)
  129. void g_static_mutex_free (GStaticMutex *mutex);
  130. GLIB_DEPRECATED_IN_2_32_FOR(GMutex)
  131. GMutex *g_static_mutex_get_mutex_impl (GStaticMutex *mutex);
  132. typedef struct _GStaticRecMutex GStaticRecMutex GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRecMutex);
  133. struct _GStaticRecMutex
  134. {
  135. /*< private >*/
  136. GStaticMutex mutex;
  137. guint depth;
  138. /* ABI compat only */
  139. union {
  140. #ifdef G_OS_WIN32
  141. void *owner;
  142. #else
  143. pthread_t owner;
  144. #endif
  145. gdouble dummy;
  146. } unused;
  147. } GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRecMutex);
  148. #define G_STATIC_REC_MUTEX_INIT { G_STATIC_MUTEX_INIT, 0, { 0 } } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_rec_mutex_init)
  149. GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_init)
  150. void g_static_rec_mutex_init (GStaticRecMutex *mutex);
  151. GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_lock)
  152. void g_static_rec_mutex_lock (GStaticRecMutex *mutex);
  153. GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_try_lock)
  154. gboolean g_static_rec_mutex_trylock (GStaticRecMutex *mutex);
  155. GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_unlock)
  156. void g_static_rec_mutex_unlock (GStaticRecMutex *mutex);
  157. GLIB_DEPRECATED_IN_2_32
  158. void g_static_rec_mutex_lock_full (GStaticRecMutex *mutex,
  159. guint depth);
  160. GLIB_DEPRECATED_IN_2_32
  161. guint g_static_rec_mutex_unlock_full (GStaticRecMutex *mutex);
  162. GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_free)
  163. void g_static_rec_mutex_free (GStaticRecMutex *mutex);
  164. typedef struct _GStaticRWLock GStaticRWLock GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRWLock);
  165. struct _GStaticRWLock
  166. {
  167. /*< private >*/
  168. GStaticMutex mutex;
  169. GCond *read_cond;
  170. GCond *write_cond;
  171. guint read_counter;
  172. gboolean have_writer;
  173. guint want_to_read;
  174. guint want_to_write;
  175. } GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRWLock);
  176. #define G_STATIC_RW_LOCK_INIT { G_STATIC_MUTEX_INIT, NULL, NULL, 0, FALSE, 0, 0 } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_rw_lock_init)
  177. GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_init)
  178. void g_static_rw_lock_init (GStaticRWLock *lock);
  179. GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_reader_lock)
  180. void g_static_rw_lock_reader_lock (GStaticRWLock *lock);
  181. GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_reader_trylock)
  182. gboolean g_static_rw_lock_reader_trylock (GStaticRWLock *lock);
  183. GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_reader_unlock)
  184. void g_static_rw_lock_reader_unlock (GStaticRWLock *lock);
  185. GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_writer_lock)
  186. void g_static_rw_lock_writer_lock (GStaticRWLock *lock);
  187. GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_writer_trylock)
  188. gboolean g_static_rw_lock_writer_trylock (GStaticRWLock *lock);
  189. GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_writer_unlock)
  190. void g_static_rw_lock_writer_unlock (GStaticRWLock *lock);
  191. GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_free)
  192. void g_static_rw_lock_free (GStaticRWLock *lock);
  193. GLIB_DEPRECATED_IN_2_32
  194. GPrivate * g_private_new (GDestroyNotify notify);
  195. typedef struct _GStaticPrivate GStaticPrivate GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GPrivate);
  196. struct _GStaticPrivate
  197. {
  198. /*< private >*/
  199. guint index;
  200. } GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GPrivate);
  201. #define G_STATIC_PRIVATE_INIT { 0 } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(G_PRIVATE_INIT)
  202. GLIB_DEPRECATED_IN_2_32
  203. void g_static_private_init (GStaticPrivate *private_key);
  204. GLIB_DEPRECATED_IN_2_32_FOR(g_private_get)
  205. gpointer g_static_private_get (GStaticPrivate *private_key);
  206. GLIB_DEPRECATED_IN_2_32_FOR(g_private_set)
  207. void g_static_private_set (GStaticPrivate *private_key,
  208. gpointer data,
  209. GDestroyNotify notify);
  210. GLIB_DEPRECATED_IN_2_32
  211. void g_static_private_free (GStaticPrivate *private_key);
  212. GLIB_DEPRECATED_IN_2_32
  213. gboolean g_once_init_enter_impl (volatile gsize *location);
  214. GLIB_DEPRECATED_IN_2_32
  215. void g_thread_init (gpointer vtable);
  216. GLIB_DEPRECATED_IN_2_32
  217. void g_thread_init_with_errorcheck_mutexes (gpointer vtable);
  218. GLIB_DEPRECATED_IN_2_32
  219. gboolean g_thread_get_initialized (void);
  220. GLIB_VAR gboolean g_threads_got_initialized;
  221. #define g_thread_supported() (1) GLIB_DEPRECATED_MACRO_IN_2_32
  222. GLIB_DEPRECATED_IN_2_32
  223. GMutex * g_mutex_new (void);
  224. GLIB_DEPRECATED_IN_2_32
  225. void g_mutex_free (GMutex *mutex);
  226. GLIB_DEPRECATED_IN_2_32
  227. GCond * g_cond_new (void);
  228. GLIB_DEPRECATED_IN_2_32
  229. void g_cond_free (GCond *cond);
  230. GLIB_DEPRECATED_IN_2_32
  231. gboolean g_cond_timed_wait (GCond *cond,
  232. GMutex *mutex,
  233. GTimeVal *timeval);
  234. G_GNUC_END_IGNORE_DEPRECATIONS
  235. G_END_DECLS
  236. #endif /* __G_DEPRECATED_THREAD_H__ */