Ruby  2.5.0dev(2017-10-22revision60238)
thread_native.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  thread_native.h -
4 
5  $Author: ko1 $
6  created at: Wed May 14 19:37:31 2014
7 
8  Copyright (C) 2014 Yukihiro Matsumoto
9 
10 **********************************************************************/
11 
12 #ifndef RUBY_THREAD_NATIVE_H
13 #define RUBY_THREAD_NATIVE_H 1
14 
15 /*
16  * This file contains wrapper APIs for native thread primitives
17  * which Ruby interpreter uses.
18  *
19  * Now, we only suppors pthread and Windows threads.
20  *
21  * If you want to use Ruby's Mutex and so on to synchronize Ruby Threads,
22  * please use Mutex directly.
23  */
24 
25 
26 #if defined(_WIN32)
27 #include <windows.h>
28 typedef HANDLE rb_nativethread_id_t;
29 
30 typedef union rb_thread_lock_union {
31  HANDLE mutex;
32  CRITICAL_SECTION crit;
33 } rb_nativethread_lock_t;
34 
35 #elif defined(HAVE_PTHREAD_H)
36 #include <pthread.h>
37 typedef pthread_t rb_nativethread_id_t;
38 typedef pthread_mutex_t rb_nativethread_lock_t;
39 
40 #else
41 #error "unsupported thread type"
42 
43 #endif
44 
46 
47 rb_nativethread_id_t rb_nativethread_self();
48 
49 void rb_nativethread_lock_initialize(rb_nativethread_lock_t *lock);
50 void rb_nativethread_lock_destroy(rb_nativethread_lock_t *lock);
51 void rb_nativethread_lock_lock(rb_nativethread_lock_t *lock);
52 void rb_nativethread_lock_unlock(rb_nativethread_lock_t *lock);
53 
55 
56 #endif
RUBY_SYMBOL_EXPORT_BEGIN rb_nativethread_id_t rb_nativethread_self()
void rb_nativethread_lock_destroy(rb_nativethread_lock_t *lock)
Definition: thread.c:362
void rb_nativethread_lock_unlock(rb_nativethread_lock_t *lock)
Definition: thread.c:374
#define RUBY_SYMBOL_EXPORT_END
Definition: missing.h:49
#define RUBY_SYMBOL_EXPORT_BEGIN
Definition: missing.h:48
void rb_nativethread_lock_initialize(rb_nativethread_lock_t *lock)
Definition: thread.c:356
void rb_nativethread_lock_lock(rb_nativethread_lock_t *lock)
Definition: thread.c:368