本文整理汇总了C++中pthread_key_create函数的典型用法代码示例。如果您正苦于以下问题:C++ pthread_key_create函数的具体用法?C++ pthread_key_create怎么用?C++ pthread_key_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pthread_key_create函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_key_once
static void create_key_once(void)
{
pthread_key_create(&g_key, NULL);
}
示例2: Deleter
Deleter()
{
pthread_key_create(&pkey_, &ThreadLocalSingleton::destructor);
}
示例3: make_key
static void
make_key()
{
(void) pthread_key_create(&tlsKey, NULL);
}
示例4: icalerrno_key_alloc
static void icalerrno_key_alloc(void) {
pthread_key_create(&icalerrno_key, icalerrno_destroy);
}
示例5: l_random_setup
void
l_random_setup(void)
{
pthread_key_create(&key, l_random_key_destructor);
}
示例6: ecpg_actual_connection_init
static void
ecpg_actual_connection_init(void)
{
pthread_key_create(&actual_connection_key, NULL);
}
示例7: emutls_init
static __inline void emutls_init(void) {
if (pthread_key_create(&emutls_pthread_key, emutls_key_destructor) != 0)
abort();
emutls_key_created = true;
}
示例8: ThreadLocal
ThreadLocal(bool destroy = true)
{
pthread_key_create(&m_key,
destroy ? &ThreadLocal::Destroy : &ThreadLocal::Empty);
}
示例9: thread_init
static void thread_init(void)
{
pthread_key_create(&__ph_thread_key, destroy_thread);
ck_epoch_init(&misc_epoch);
}
示例10: taskLibInit
/*
* TaskLib init function
*/
STATUS
taskLibInit(void)
{
OS_TCB *tcb;
struct sched_param param;
int policy;
char name[12];
/* Determine the min and max allowable priorities */
#ifdef PTHREAD_MIN_PRIORITY
rr_min_priority = PTHREAD_MIN_PRIORITY;
#else
rr_min_priority = sched_get_priority_min (SCHED_RR);
#endif
#ifdef PTHREAD_MAX_PRIORITY
rr_max_priority = PTHREAD_MAX_PRIORITY;
#else
rr_max_priority = sched_get_priority_max (SCHED_RR);
#endif
/* Create a thread specific key to access TCB */
pthread_key_create(&taskControlBlock, NULL);
/* allocate a TCB for main thread */
tcb = (OS_TCB *)malloc(sizeof(OS_TCB));
if (tcb == NULL) {
return ERROR;
}
snprintf(name, sizeof(name), "tUnix%d", (int)getpid());
tcb->name = strdup(name);
#ifdef HAVE_PTHREAD_ATTR_SETSCHEDPOLICY
pthread_getschedparam(pthread_self(), &policy, ¶m);
#else
policy = 0;
param.sched_priority = rr_min_priority;
#endif
tcb->policy = policy;
tcb->priority = priorityPosixToVx(param.sched_priority);
tcb->options = 0;
tcb->entry = NULL; /* implicit main() */
tcb->errorStatus = errno;
/* Process and thread ids */
tcb->pid = getpid();
tcb->tid = pthread_self();
/* The tcb list is initially empty */
tcb->next = NULL;
/* Mark the TCB */
tcb->magic = TASK_MAGIC;
/* Register the TCB pointer in the thread-specific key */
#ifdef DEBUG
fprintf(stderr, "registering task specific value %lu %lu\n",
(unsigned long)tcb, (unsigned long)pthread_self());
#endif
if (pthread_setspecific(taskControlBlock, (void *)tcb) != 0) {
errnoSet(errno);
return ERROR;
}
/* Initialize the global task List */
taskList = tcb;
return OK;
}
示例11: initThreadLocal
void initThreadLocal(JNIEnv* env) {
pthread_key_create(&gTlsKey, destroyThreadLocal);
}
示例12: x_init
void x_init()
{
pthread_key_create(&g_except_key, NULL);
pthread_key_create(&g_error_key, NULL);
}
示例13: _xc_init_errbuf
static void
_xc_init_errbuf(void)
{
pthread_key_create(&errbuf_pkey, _xc_clean_errbuf);
}
示例14: tsd_create
// NOTE: glibc used uint as pthread_key_t.
void
tsd_create(uint_t * key, void (*exit)(void *))
{
VERIFY0(pthread_key_create(key, exit));
}
示例15: np_init_error_key
static void
np_init_error_key()
{
pthread_key_create(&error_key, np_destroy_error);
}