ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
threading.c File Reference

Threading abstraction for WASM/Emscripten using pthreads. More...

Go to the source code of this file.

Functions

int mutex_init (mutex_t *mutex)
 
int mutex_destroy (mutex_t *mutex)
 
int mutex_lock_impl (mutex_t *mutex)
 
int mutex_trylock_impl (mutex_t *mutex)
 
int mutex_unlock_impl (mutex_t *mutex)
 
int asciichat_thread_create (asciichat_thread_t *thread, void *(*start_routine)(void *), void *arg)
 
int asciichat_thread_join (asciichat_thread_t *thread, void **retval)
 
int asciichat_thread_detach (asciichat_thread_t *thread)
 
asciichat_thread_t asciichat_thread_self (void)
 
int asciichat_thread_equal (asciichat_thread_t t1, asciichat_thread_t t2)
 
int rwlock_init (rwlock_t *rwlock)
 
int rwlock_rdlock_impl (rwlock_t *rwlock)
 
int rwlock_wrlock_impl (rwlock_t *rwlock)
 
int rwlock_rdunlock_impl (rwlock_t *rwlock)
 
int rwlock_wrunlock_impl (rwlock_t *rwlock)
 
uint64_t asciichat_thread_current_id (void)
 
int ascii_tls_key_create (tls_key_t *key, void(*destructor)(void *))
 
int ascii_tls_key_delete (tls_key_t key)
 
void * ascii_tls_get (tls_key_t key)
 
int ascii_tls_set (tls_key_t key, void *value)
 

Detailed Description

Threading abstraction for WASM/Emscripten using pthreads.

Definition in file threading.c.

Function Documentation

◆ ascii_tls_get()

void * ascii_tls_get ( tls_key_t  key)

Definition at line 97 of file threading.c.

97 {
98 return pthread_getspecific(key);
99}

Referenced by asciichat_instr_runtime_get().

◆ ascii_tls_key_create()

int ascii_tls_key_create ( tls_key_t *  key,
void(*)(void *)  destructor 
)

Definition at line 89 of file threading.c.

89 {
90 return pthread_key_create(key, destructor);
91}

◆ ascii_tls_key_delete()

int ascii_tls_key_delete ( tls_key_t  key)

Definition at line 93 of file threading.c.

93 {
94 return pthread_key_delete(key);
95}

Referenced by asciichat_instr_runtime_global_destroy().

◆ ascii_tls_set()

int ascii_tls_set ( tls_key_t  key,
void *  value 
)

Definition at line 101 of file threading.c.

101 {
102 return pthread_setspecific(key, value);
103}

Referenced by asciichat_instr_runtime_get().

◆ asciichat_thread_create()

◆ asciichat_thread_current_id()

uint64_t asciichat_thread_current_id ( void  )

Definition at line 84 of file threading.c.

84 {
85 return (uint64_t)pthread_self();
86}

Referenced by asciichat_instr_runtime_get(), log_json_async_safe(), and log_json_write().

◆ asciichat_thread_detach()

int asciichat_thread_detach ( asciichat_thread_t *  thread)

Definition at line 50 of file threading.c.

50 {
51 return pthread_detach(*thread);
52}

◆ asciichat_thread_equal()

int asciichat_thread_equal ( asciichat_thread_t  t1,
asciichat_thread_t  t2 
)

Definition at line 58 of file threading.c.

58 {
59 return pthread_equal(t1, t2);
60}

Referenced by remove_client().

◆ asciichat_thread_join()

◆ asciichat_thread_self()

asciichat_thread_t asciichat_thread_self ( void  )

Definition at line 54 of file threading.c.

54 {
55 return pthread_self();
56}

Referenced by client_receive_thread(), log_lock_terminal(), log_plain_msg(), platform_print_backtrace_symbols(), and remove_client().

◆ mutex_destroy()

◆ mutex_init()

◆ mutex_lock_impl()

int mutex_lock_impl ( mutex_t *  mutex)

Definition at line 26 of file threading.c.

26 {
27 (void)mutex;
28 return 0; // Success - no-op
29}

Referenced by debug_mutex_lock().

◆ mutex_trylock_impl()

int mutex_trylock_impl ( mutex_t *  mutex)

Definition at line 31 of file threading.c.

31 {
32 (void)mutex;
33 return 0; // Success - no-op
34}

Referenced by debug_mutex_trylock().

◆ mutex_unlock_impl()

int mutex_unlock_impl ( mutex_t *  mutex)

Definition at line 36 of file threading.c.

36 {
37 (void)mutex;
38 return 0; // Success - no-op
39}

Referenced by debug_mutex_unlock().

◆ rwlock_init()

int rwlock_init ( rwlock_t *  rwlock)

Definition at line 63 of file threading.c.

63 {
64 return pthread_rwlock_init(rwlock, NULL);
65}
rwlock_t rwlock
Read-write lock for thread-safe access (uthash requires external locking)
Definition util/time.c:32

References rwlock.

Referenced by mixer_create(), server_main(), symbol_cache_init(), and timer_system_init().

◆ rwlock_rdlock_impl()

int rwlock_rdlock_impl ( rwlock_t *  rwlock)

Definition at line 67 of file threading.c.

67 {
68 return pthread_rwlock_rdlock(rwlock);
69}

References rwlock.

Referenced by debug_rwlock_rdlock().

◆ rwlock_rdunlock_impl()

int rwlock_rdunlock_impl ( rwlock_t *  rwlock)

Definition at line 75 of file threading.c.

75 {
76 return pthread_rwlock_unlock(rwlock);
77}

References rwlock.

Referenced by debug_rwlock_rdunlock().

◆ rwlock_wrlock_impl()

int rwlock_wrlock_impl ( rwlock_t *  rwlock)

Definition at line 71 of file threading.c.

71 {
72 return pthread_rwlock_wrlock(rwlock);
73}

References rwlock.

Referenced by debug_rwlock_wrlock().

◆ rwlock_wrunlock_impl()

int rwlock_wrunlock_impl ( rwlock_t *  rwlock)

Definition at line 79 of file threading.c.

79 {
80 return pthread_rwlock_unlock(rwlock);
81}

References rwlock.

Referenced by debug_rwlock_wrunlock().