g_thread_init
NAME
g_thread_init?- 初始化線程系統(tǒng)
?
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
如果你在多個(gè)線程中使用Glib,那么你必須調(diào)用這個(gè)函數(shù)來(lái)初始化線程系統(tǒng).
該函數(shù)不可以在Glib的CallBack中直接或間接被調(diào)用,Also no mutexes may be currently locked while calling?g_thread_init()。
使用該函數(shù)必須連接gthread庫(kù),`pkg-config --libs gthread-2.0`
從v2.24版本開(kāi)始,允許多次調(diào)用該函數(shù),但是只有第一次調(diào)用有效,其他調(diào)用無(wú)效。
從v2.32版本開(kāi)始,Glib不再支持自定義線程實(shí)現(xiàn),vtable 參數(shù)會(huì)被忽略,所以參數(shù)?vtable 應(yīng)該設(shè)置為NULL;
從v2.32版本開(kāi)始,該函數(shù)已被棄用,因?yàn)镚lib系統(tǒng)會(huì)在程序開(kāi)始前自動(dòng)完成線程系統(tǒng)初始化。?
?
PARAMETERS
①vtable
GThreadFunctions類(lèi)型的函數(shù)table, v2.32版本后應(yīng)該設(shè)置為NULL
?
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/LubinLew/p/GLIB-g_thread_init.html
總結(jié)
以上是生活随笔為你收集整理的g_thread_init的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 父亲节感恩回馈PSD海报
- 下一篇: SD卡FAT32文件系统格式