g_thread_init


NAME

g_thread_init - 初始化線程系統

 

SYNOPSIS 

#include <glib.h> //in gthread.h

  void g_thread_init (GThreadFunctions *vtable);  

 

Date Structure 

typedef struct _GThreadFunctions GThreadFunctions;
struct _GThreadFunctions
{
  GMutex*  (*mutex_new)           (void);
  void     (*mutex_lock)          (GMutex               *mutex);
  gboolean (*mutex_trylock)       (GMutex               *mutex);
  void     (*mutex_unlock)        (GMutex               *mutex);
  void     (*mutex_free)          (GMutex               *mutex);
  GCond*   (*cond_new)            (void);
  void     (*cond_signal)         (GCond                *cond);
  void     (*cond_broadcast)      (GCond                *cond);
  void     (*cond_wait)           (GCond                *cond,
                                   GMutex               *mutex);
  gboolean (*cond_timed_wait)     (GCond                *cond,
                                   GMutex               *mutex,
                                   GTimeVal             *end_time);
  void      (*cond_free)          (GCond                *cond);
  GPrivate* (*private_new)        (GDestroyNotify        destructor);
  gpointer  (*private_get)        (GPrivate             *private_key);
  void      (*private_set)        (GPrivate             *private_key,
                                   gpointer              data);
  void      (*thread_create)      (GThreadFunc           func,
                                   gpointer              data,
                                   gulong                stack_size,
                                   gboolean              joinable,
                                   gboolean              bound,
                                   GThreadPriority       priority,
                                   gpointer              thread,
                                   GError              **error);
  void      (*thread_yield)       (void);
  void      (*thread_join)        (gpointer              thread);
  void      (*thread_exit)        (void);
  void      (*thread_set_priority)(gpointer              thread,
                                   GThreadPriority       priority);
  void      (*thread_self)        (gpointer              thread);
  gboolean  (*thread_equal)       (gpointer              thread1,
                   gpointer              thread2);
};
GThreadFunctions

 

DESCRIPTION

如果你在多個線程中使用Glib,那么你必須調用這個函數來初始化線程系統.

該函數不可以在Glib的CallBack中直接或間接被調用,Also no mutexes may be currently locked while calling g_thread_init()。

使用該函數必須連接gthread庫,`pkg-config --libs gthread-2.0`

從v2.24版本開始,允許多次調用該函數,但是只有第一次調用有效,其他調用無效。

從v2.32版本開始,Glib不再支持自定義線程實現,vtable 參數會被忽略,所以參數 vtable 應該設置為NULL;

從v2.32版本開始,該函數已被棄用,因為Glib系統會在程序開始前自動完成線程系統初始化 

 

PARAMETERS

vtable

GThreadFunctions類型的函數table, v2.32版本后應該設置為NULL

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM