#include "uv.h"
#include "internal.h"
#include <pthread.h>
#include <assert.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
#include <limits.h>
Go to the source code of this file.
|
| int | uv_barrier_init (uv_barrier_t *barrier, unsigned int count) |
| |
| int | uv_barrier_wait (uv_barrier_t *barrier) |
| |
| void | uv_barrier_destroy (uv_barrier_t *barrier) |
| |
| static size_t | thread_stack_size (void) |
| |
| int | uv_thread_create (uv_thread_t *tid, void(*entry)(void *arg), void *arg) |
| |
| int | uv_thread_create_ex (uv_thread_t *tid, const uv_thread_options_t *params, void(*entry)(void *arg), void *arg) |
| |
| uv_thread_t | uv_thread_self (void) |
| |
| int | uv_thread_join (uv_thread_t *tid) |
| |
| int | uv_thread_equal (const uv_thread_t *t1, const uv_thread_t *t2) |
| |
| int | uv_mutex_init (uv_mutex_t *mutex) |
| |
| int | uv_mutex_init_recursive (uv_mutex_t *mutex) |
| |
| void | uv_mutex_destroy (uv_mutex_t *mutex) |
| |
| void | uv_mutex_lock (uv_mutex_t *mutex) |
| |
| int | uv_mutex_trylock (uv_mutex_t *mutex) |
| |
| void | uv_mutex_unlock (uv_mutex_t *mutex) |
| |
| int | uv_rwlock_init (uv_rwlock_t *rwlock) |
| |
| void | uv_rwlock_destroy (uv_rwlock_t *rwlock) |
| |
| void | uv_rwlock_rdlock (uv_rwlock_t *rwlock) |
| |
| int | uv_rwlock_tryrdlock (uv_rwlock_t *rwlock) |
| |
| void | uv_rwlock_rdunlock (uv_rwlock_t *rwlock) |
| |
| void | uv_rwlock_wrlock (uv_rwlock_t *rwlock) |
| |
| int | uv_rwlock_trywrlock (uv_rwlock_t *rwlock) |
| |
| void | uv_rwlock_wrunlock (uv_rwlock_t *rwlock) |
| |
| void | uv_once (uv_once_t *guard, void(*callback)(void)) |
| |
| static int | uv__custom_sem_init (uv_sem_t *sem_, unsigned int value) |
| |
| static void | uv__custom_sem_destroy (uv_sem_t *sem_) |
| |
| static void | uv__custom_sem_post (uv_sem_t *sem_) |
| |
| static void | uv__custom_sem_wait (uv_sem_t *sem_) |
| |
| static int | uv__custom_sem_trywait (uv_sem_t *sem_) |
| |
| static int | uv__sem_init (uv_sem_t *sem, unsigned int value) |
| |
| static void | uv__sem_destroy (uv_sem_t *sem) |
| |
| static void | uv__sem_post (uv_sem_t *sem) |
| |
| static void | uv__sem_wait (uv_sem_t *sem) |
| |
| static int | uv__sem_trywait (uv_sem_t *sem) |
| |
| int | uv_sem_init (uv_sem_t *sem, unsigned int value) |
| |
| void | uv_sem_destroy (uv_sem_t *sem) |
| |
| void | uv_sem_post (uv_sem_t *sem) |
| |
| void | uv_sem_wait (uv_sem_t *sem) |
| |
| int | uv_sem_trywait (uv_sem_t *sem) |
| |
| int | uv_cond_init (uv_cond_t *cond) |
| |
| void | uv_cond_destroy (uv_cond_t *cond) |
| |
| void | uv_cond_signal (uv_cond_t *cond) |
| |
| void | uv_cond_broadcast (uv_cond_t *cond) |
| |
| void | uv_cond_wait (uv_cond_t *cond, uv_mutex_t *mutex) |
| |
| int | uv_cond_timedwait (uv_cond_t *cond, uv_mutex_t *mutex, uint64_t timeout) |
| |
| int | uv_key_create (uv_key_t *key) |
| |
| void | uv_key_delete (uv_key_t *key) |
| |
| void * | uv_key_get (uv_key_t *key) |
| |
| void | uv_key_set (uv_key_t *key, void *value) |
| |
◆ NANOSEC
◆ platform_needs_custom_semaphore
| #define platform_needs_custom_semaphore 0 |
◆ uv_semaphore_t
◆ thread_stack_size()
| static size_t thread_stack_size |
( |
void |
| ) |
|
|
static |
Definition at line 171 of file thread.c.
172 #if defined(__APPLE__) || defined(__linux__)
179 if (0 == getrlimit(RLIMIT_STACK, &lim) && lim.rlim_cur != RLIM_INFINITY) {
181 lim.rlim_cur -= lim.rlim_cur % (rlim_t) getpagesize();
194 if (lim.rlim_cur >= 8192)
195 if (lim.rlim_cur >= PTHREAD_STACK_MIN)
200 #if !defined(__linux__)
202 #elif defined(__PPC__) || defined(__ppc__) || defined(__powerpc__)
Referenced by uv_thread_create_ex().
◆ uv__custom_sem_destroy()
| static void uv__custom_sem_destroy |
( |
uv_sem_t * |
sem_ | ) |
|
|
static |
◆ uv__custom_sem_init()
Definition at line 526 of file thread.c.
int uv_cond_init(uv_cond_t *cond)
int uv_mutex_init(uv_mutex_t *mutex)
void * uv__malloc(size_t size)
References uv_semaphore_s::cond, err, uv_semaphore_s::mutex, NULL, uv__free(), uv__malloc(), uv_cond_init(), uv_mutex_destroy(), uv_mutex_init(), value, and uv_semaphore_s::value.
Referenced by uv_sem_init().
◆ uv__custom_sem_post()
| static void uv__custom_sem_post |
( |
uv_sem_t * |
sem_ | ) |
|
|
static |
◆ uv__custom_sem_trywait()
◆ uv__custom_sem_wait()
| static void uv__custom_sem_wait |
( |
uv_sem_t * |
sem_ | ) |
|
|
static |
◆ uv__sem_destroy()
| static void uv__sem_destroy |
( |
uv_sem_t * |
sem | ) |
|
|
static |
◆ uv__sem_init()
◆ uv__sem_post()
| static void uv__sem_post |
( |
uv_sem_t * |
sem | ) |
|
|
static |
◆ uv__sem_trywait()
◆ uv__sem_wait()
| static void uv__sem_wait |
( |
uv_sem_t * |
sem | ) |
|
|
static |
◆ uv_barrier_destroy()
Definition at line 118 of file thread.c.
127 if (
b->in != 0 ||
b->out != 0)
assert(limit<=UINT32_MAX/2)
◆ uv_barrier_init()
Definition at line 55 of file thread.c.
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
void error(const char *msg)
◆ uv_barrier_wait()
Definition at line 89 of file thread.c.
93 if (barrier ==
NULL || barrier->
b ==
NULL)
99 if (++
b->in ==
b->threshold) {
101 b->out =
b->threshold;
109 last = (--
b->out == 0);
◆ uv_cond_broadcast()
Definition at line 774 of file thread.c.
775 if (pthread_cond_broadcast(
cond))
#define cond(bop, top, mask, flags)
◆ uv_cond_destroy()
◆ uv_cond_init()
Definition at line 704 of file thread.c.
705 pthread_condattr_t attr;
708 err = pthread_condattr_init(&attr);
712 err = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
716 err = pthread_cond_init(
cond, &attr);
720 err = pthread_condattr_destroy(&attr);
727 pthread_cond_destroy(
cond);
729 pthread_condattr_destroy(&attr);
Referenced by uv__custom_sem_init(), and uv_barrier_init().
◆ uv_cond_signal()
◆ uv_cond_timedwait()
Definition at line 785 of file thread.c.
792 #if defined(__APPLE__) && defined(__MACH__)
795 r = pthread_cond_timedwait_relative_np(
cond,
mutex, &ts);
uint64_t uv__hrtime(uv_clocktype_t type)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval tv
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog gettimeofday
◆ uv_cond_wait()
◆ uv_key_create()
Definition at line 823 of file thread.c.
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
Referenced by uv__init_current_thread_key().
◆ uv_key_delete()
Definition at line 828 of file thread.c.
829 if (pthread_key_delete(*
key))
◆ uv_key_get()
◆ uv_key_set()
| void uv_key_set |
( |
uv_key_t * |
key, |
|
|
void * |
value |
|
) |
| |
◆ uv_mutex_destroy()
◆ uv_mutex_init()
Definition at line 282 of file thread.c.
283 #if defined(NDEBUG) || !defined(PTHREAD_MUTEX_ERRORCHECK)
286 pthread_mutexattr_t attr;
289 if (pthread_mutexattr_init(&attr))
292 if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK))
295 err = pthread_mutex_init(
mutex, &attr);
297 if (pthread_mutexattr_destroy(&attr))
Referenced by uv__custom_sem_init(), uv_barrier_init(), and uv_mutex_init_recursive().
◆ uv_mutex_init_recursive()
Definition at line 305 of file thread.c.
306 pthread_mutexattr_t attr;
309 if (pthread_mutexattr_init(&attr))
312 if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE))
315 err = pthread_mutex_init(
mutex, &attr);
317 if (pthread_mutexattr_destroy(&attr))
◆ uv_mutex_lock()
◆ uv_mutex_trylock()
◆ uv_mutex_unlock()
◆ uv_once()
| void uv_once |
( |
uv_once_t * |
guard, |
|
|
void(*)(void) |
callback |
|
) |
| |
◆ uv_rwlock_destroy()
Definition at line 361 of file thread.c.
362 if (pthread_rwlock_destroy(rwlock))
◆ uv_rwlock_init()
◆ uv_rwlock_rdlock()
Definition at line 367 of file thread.c.
368 if (pthread_rwlock_rdlock(rwlock))
◆ uv_rwlock_rdunlock()
Definition at line 387 of file thread.c.
388 if (pthread_rwlock_unlock(rwlock))
◆ uv_rwlock_tryrdlock()
Definition at line 373 of file thread.c.
376 err = pthread_rwlock_tryrdlock(rwlock);
◆ uv_rwlock_trywrlock()
Definition at line 399 of file thread.c.
402 err = pthread_rwlock_trywrlock(rwlock);
◆ uv_rwlock_wrlock()
Definition at line 393 of file thread.c.
394 if (pthread_rwlock_wrlock(rwlock))
◆ uv_rwlock_wrunlock()
Definition at line 413 of file thread.c.
414 if (pthread_rwlock_unlock(rwlock))
◆ uv_sem_destroy()
◆ uv_sem_init()
Definition at line 650 of file thread.c.
651 #if defined(__GLIBC__) && !defined(__UCLIBC__)
652 uv_once(&glibc_version_check_once, glibc_version_check);
void uv_once(uv_once_t *guard, void(*callback)(void))
static int uv__custom_sem_init(uv_sem_t *sem_, unsigned int value)
static int uv__sem_init(uv_sem_t *sem, unsigned int value)
Referenced by uv_barrier_init().
◆ uv_sem_post()
Definition at line 670 of file thread.c.
static void uv__custom_sem_post(uv_sem_t *sem_)
static void uv__sem_post(uv_sem_t *sem)
Referenced by uv_barrier_wait().
◆ uv_sem_trywait()
Definition at line 686 of file thread.c.
static int uv__custom_sem_trywait(uv_sem_t *sem_)
static int uv__sem_trywait(uv_sem_t *sem)
◆ uv_sem_wait()
Definition at line 678 of file thread.c.
static void uv__custom_sem_wait(uv_sem_t *sem_)
static void uv__sem_wait(uv_sem_t *sem)
Referenced by uv_barrier_wait().
◆ uv_thread_create()
Definition at line 210 of file thread.c.
int uv_thread_create_ex(uv_thread_t *tid, const uv_thread_options_t *params, void(*entry)(void *arg), void *arg)
◆ uv_thread_create_ex()
Definition at line 216 of file thread.c.
221 pthread_attr_t* attr;
222 pthread_attr_t attr_storage;
236 if (stack_size == 0) {
239 pagesize = (
size_t)getpagesize();
241 stack_size = (stack_size + pagesize - 1) &~ (pagesize - 1);
242 #ifdef PTHREAD_STACK_MIN
243 if (stack_size < PTHREAD_STACK_MIN)
244 stack_size = PTHREAD_STACK_MIN;
248 if (stack_size > 0) {
249 attr = &attr_storage;
251 if (pthread_attr_init(attr))
254 if (pthread_attr_setstacksize(attr, stack_size))
259 err = pthread_create(tid, attr,
f.out,
arg);
262 pthread_attr_destroy(attr);
const lzma_allocator const uint8_t * in
static size_t thread_stack_size(void)
@ UV_THREAD_HAS_STACK_SIZE
Referenced by uv_thread_create().
◆ uv_thread_equal()
Definition at line 277 of file thread.c.
278 return pthread_equal(*
t1, *t2);
◆ uv_thread_join()
◆ uv_thread_self()
Definition at line 268 of file thread.c.
269 return pthread_self();