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

 

 

 

转载于:https://www.cnblogs.com/LubinLew/p/GLIB-g_thread_init.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值