Ruby  3.1.4p223 (2023-03-30 revision HEAD)
thread_native.h
Go to the documentation of this file.
1 #ifndef RUBY_THREAD_NATIVE_H /*-*-C++-*-vi:se ft=cpp:*/
2 #define RUBY_THREAD_NATIVE_H 1
22 #if defined(_WIN32)
23 #include <windows.h>
24 typedef HANDLE rb_nativethread_id_t;
25 
26 typedef union rb_thread_lock_union {
27  HANDLE mutex;
28  CRITICAL_SECTION crit;
29 } rb_nativethread_lock_t;
30 
31 typedef struct rb_thread_cond_struct rb_nativethread_cond_t;
32 
33 #elif defined(HAVE_PTHREAD_H)
34 
35 #include <pthread.h>
36 typedef pthread_t rb_nativethread_id_t;
37 typedef pthread_mutex_t rb_nativethread_lock_t;
38 typedef pthread_cond_t rb_nativethread_cond_t;
39 
40 #elif defined(__DOXYGEN__)
41 
43 struct rb_nativethread_id_t;
44 
46 struct rb_nativethread_lock_t;
47 
49 struct rb_nativethread_cond_t;
50 
51 #else
52 #error "unsupported thread type"
53 
54 #endif
55 
57 
58 
63 rb_nativethread_id_t rb_nativethread_self(void);
64 
77 void rb_nativethread_lock_initialize(rb_nativethread_lock_t *lock);
78 
96 void rb_nativethread_lock_destroy(rb_nativethread_lock_t *lock);
97 
104 void rb_nativethread_lock_lock(rb_nativethread_lock_t *lock);
105 
113 void rb_nativethread_lock_unlock(rb_nativethread_lock_t *lock);
114 
116 void rb_native_mutex_lock(rb_nativethread_lock_t *lock);
117 
126 int rb_native_mutex_trylock(rb_nativethread_lock_t *lock);
127 
129 void rb_native_mutex_unlock(rb_nativethread_lock_t *lock);
130 
132 void rb_native_mutex_initialize(rb_nativethread_lock_t *lock);
133 
135 void rb_native_mutex_destroy(rb_nativethread_lock_t *lock);
136 
147 void rb_native_cond_signal(rb_nativethread_cond_t *cond);
148 
155 void rb_native_cond_broadcast(rb_nativethread_cond_t *cond);
156 
166 void rb_native_cond_wait(rb_nativethread_cond_t *cond, rb_nativethread_lock_t *mutex);
167 
180 void rb_native_cond_timedwait(rb_nativethread_cond_t *cond, rb_nativethread_lock_t *mutex, unsigned long msec);
181 
188 void rb_native_cond_initialize(rb_nativethread_cond_t *cond);
189 
196 void rb_native_cond_destroy(rb_nativethread_cond_t *cond);
197 
199 #endif
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:106
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:97
void rb_nativethread_lock_lock(rb_nativethread_lock_t *lock)
Blocks until the current thread obtains a lock.
Definition: thread.c:440
rb_nativethread_id_t rb_nativethread_self(void)
Queries the ID of the native thread that is calling this function.
void rb_native_mutex_lock(rb_nativethread_lock_t *lock)
Just another name of rb_nativethread_lock_lock.
void rb_native_cond_initialize(rb_nativethread_cond_t *cond)
Fills the passed condition variable with an initial value.
int rb_native_mutex_trylock(rb_nativethread_lock_t *lock)
Identical to rb_native_mutex_lock(), except it doesn't block in case rb_native_mutex_lock() would.
void rb_native_cond_broadcast(rb_nativethread_cond_t *cond)
Signals a condition variable.
void rb_native_mutex_initialize(rb_nativethread_lock_t *lock)
Just another name of rb_nativethread_lock_initialize.
void rb_native_mutex_unlock(rb_nativethread_lock_t *lock)
Just another name of rb_nativethread_lock_unlock.
void rb_nativethread_lock_unlock(rb_nativethread_lock_t *lock)
Releases a lock.
Definition: thread.c:446
void rb_native_mutex_destroy(rb_nativethread_lock_t *lock)
Just another name of rb_nativethread_lock_destroy.
void rb_native_cond_destroy(rb_nativethread_cond_t *cond)
Destroys the passed condition variable.
void rb_native_cond_signal(rb_nativethread_cond_t *cond)
Signals a condition variable.
void rb_nativethread_lock_initialize(rb_nativethread_lock_t *lock)
Fills the passed lock with an initial value.
Definition: thread.c:428
void rb_native_cond_wait(rb_nativethread_cond_t *cond, rb_nativethread_lock_t *mutex)
Waits for the passed condition variable to be signalled.
void rb_native_cond_timedwait(rb_nativethread_cond_t *cond, rb_nativethread_lock_t *mutex, unsigned long msec)
Identical to rb_native_cond_wait(), except it additionally takes timeout in msec resolution.
void rb_nativethread_lock_destroy(rb_nativethread_lock_t *lock)
Destroys the passed mutex.
Definition: thread.c:434