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