日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

g_thread_init

發(fā)布時(shí)間:2025/7/14 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 g_thread_init 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

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)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。