Ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a25176072e02db9254f0e0c84c805cd)
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>
28typedef HANDLE rb_nativethread_id_t;
29
30typedef union rb_thread_lock_union {
31 HANDLE mutex;
32 CRITICAL_SECTION crit;
34
35#elif defined(HAVE_PTHREAD_H)
36#include <pthread.h>
39
40#else
41#error "unsupported thread type"
42
43#endif
44
46
48
53
55
56#endif
#define RUBY_SYMBOL_EXPORT_BEGIN
#define RUBY_SYMBOL_EXPORT_END
pthread_mutex_t rb_nativethread_lock_t
pthread_t rb_nativethread_id_t
RUBY_SYMBOL_EXPORT_BEGIN rb_nativethread_id_t rb_nativethread_self()
void rb_nativethread_lock_lock(rb_nativethread_lock_t *lock)
Definition: thread.c:440
void rb_nativethread_lock_unlock(rb_nativethread_lock_t *lock)
Definition: thread.c:446
void rb_nativethread_lock_initialize(rb_nativethread_lock_t *lock)
Definition: thread.c:428
void rb_nativethread_lock_destroy(rb_nativethread_lock_t *lock)
Definition: thread.c:434