2 #include "ccan/list/list.h"
5 static VALUE rb_cMutex, rb_cQueue, rb_cSizedQueue, rb_cConditionVariable;
6 static VALUE rb_eClosedQueueError;
12 struct ccan_list_head waitq;
20 struct ccan_list_node node;
26 if (rb_fiberptr_blocking(fiber)) {
39 #define MUTEX_ALLOW_TRAP FL_USER1
42 sync_wakeup(
struct ccan_list_head *head,
long max)
44 RUBY_DEBUG_LOG(
"max:%ld", max);
48 ccan_list_for_each_safe(head, cur, next, node) {
49 ccan_list_del_init(&cur->node);
51 if (cur->th->status != THREAD_KILLED) {
52 if (cur->th->scheduler !=
Qnil && cur->fiber) {
56 RUBY_DEBUG_LOG(
"target_th:%u", rb_th_serial(cur->th));
57 rb_threadptr_interrupt(cur->th);
58 cur->th->status = THREAD_RUNNABLE;
61 if (--max == 0)
return;
67 wakeup_one(
struct ccan_list_head *head)
73 wakeup_all(
struct ccan_list_head *head)
75 sync_wakeup(head, LONG_MAX);
78 #if defined(HAVE_WORKING_FORK)
79 static void rb_mutex_abandon_all(
rb_mutex_t *mutexes);
80 static void rb_mutex_abandon_keeping_mutexes(
rb_thread_t *th);
81 static void rb_mutex_abandon_locking_mutex(
rb_thread_t *th);
109 #define mutex_mark ((void(*)(void*))0)
117 ccan_list_for_each(&mutex->waitq, w, node) {
127 mutex_free(
void *
ptr)
132 const char *err = rb_mutex_unlock_th(mutex, rb_fiber_threadptr(mutex->fiber), mutex->fiber);
133 if (err)
rb_bug(
"%s", err);
139 mutex_memsize(
const void *
ptr)
146 {mutex_mark, mutex_free, mutex_memsize,},
147 0, 0, RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY
161 rb_obj_is_mutex(
VALUE obj)
167 mutex_alloc(
VALUE klass)
174 ccan_list_head_init(&mutex->waitq);
185 mutex_initialize(
VALUE self)
193 return mutex_alloc(rb_cMutex);
207 return RBOOL(mutex->fiber);
213 if (thread->keeping_mutexes) {
214 mutex->next_mutex = thread->keeping_mutexes;
217 thread->keeping_mutexes = mutex;
223 rb_mutex_t **keeping_mutexes = &thread->keeping_mutexes;
225 while (*keeping_mutexes && *keeping_mutexes != mutex) {
227 keeping_mutexes = &(*keeping_mutexes)->next_mutex;
230 if (*keeping_mutexes) {
231 *keeping_mutexes = mutex->next_mutex;
232 mutex->next_mutex = NULL;
241 thread_mutex_insert(th, mutex);
256 if (mutex->fiber == 0) {
257 RUBY_DEBUG_LOG(
"%p ok", mutex);
261 mutex->fiber = fiber;
263 mutex_locked(th,
self);
267 RUBY_DEBUG_LOG(
"%p ng", mutex);
275 return RBOOL(mutex->fiber == fiber);
279 call_rb_fiber_scheduler_block(
VALUE mutex)
285 delete_from_waitq(
VALUE value)
296 do_mutex_lock(
VALUE self,
int interruptible_p)
306 th->ec->interrupt_mask & TRAP_INTERRUPT_MASK) {
311 if (mutex->fiber == fiber) {
315 while (mutex->fiber != fiber) {
316 VM_ASSERT(mutex->fiber != NULL);
319 if (scheduler !=
Qnil) {
323 .fiber = nonblocking_fiber(fiber)
326 ccan_list_add_tail(&mutex->waitq, &
sync_waiter.node);
331 mutex->fiber = fiber;
335 if (!th->vm->thread_ignore_deadlock && rb_fiber_threadptr(mutex->fiber) == th) {
342 .fiber = nonblocking_fiber(fiber),
345 RUBY_DEBUG_LOG(
"%p wait", mutex);
356 enum rb_thread_status prev_status = th->status;
357 th->status = THREAD_STOPPED_FOREVER;
358 rb_ractor_sleeper_threads_inc(th->ractor);
359 rb_check_deadlock(th->ractor);
361 th->locking_mutex =
self;
363 ccan_list_add_tail(&mutex->waitq, &
sync_waiter.node);
365 native_sleep(th, NULL);
371 mutex->fiber = fiber;
374 rb_ractor_sleeper_threads_dec(th->ractor);
375 th->status = prev_status;
376 th->locking_mutex =
Qfalse;
377 th->locking_mutex =
Qfalse;
379 RUBY_DEBUG_LOG(
"%p wakeup", mutex);
382 if (interruptible_p) {
385 if (mutex->fiber == fiber) mutex->fiber = 0;
386 RUBY_VM_CHECK_INTS_BLOCKING(th->ec);
388 mutex->fiber = fiber;
393 if (RUBY_VM_INTERRUPTED(th->ec)) {
395 if (saved_ints == 0) {
396 saved_ints = threadptr_get_interrupts(th);
400 threadptr_get_interrupts(th);
406 if (saved_ints) th->ec->interrupt_flag = saved_ints;
407 if (mutex->fiber == fiber) mutex_locked(th,
self);
410 RUBY_DEBUG_LOG(
"%p locked", mutex);
413 if (mutex_owned_p(fiber, mutex) ==
Qfalse)
rb_bug(
"do_mutex_lock: mutex is not owned.");
419 mutex_lock_uninterruptible(
VALUE self)
421 return do_mutex_lock(
self, 0);
434 return do_mutex_lock(
self, 1);
444 rb_mutex_owned_p(
VALUE self)
449 return mutex_owned_p(fiber, mutex);
455 RUBY_DEBUG_LOG(
"%p", mutex);
457 if (mutex->fiber == 0) {
458 return "Attempt to unlock a mutex which is not locked";
460 else if (mutex->fiber != fiber) {
461 return "Attempt to unlock a mutex which is locked by another thread/fiber";
467 thread_mutex_remove(th, mutex);
469 ccan_list_for_each_safe(&mutex->waitq, cur, next, node) {
470 ccan_list_del_init(&cur->node);
472 if (cur->th->scheduler !=
Qnil && cur->fiber) {
477 switch (cur->th->status) {
478 case THREAD_RUNNABLE:
479 case THREAD_STOPPED_FOREVER:
480 RUBY_DEBUG_LOG(
"wakeup th:%u", rb_th_serial(cur->th));
481 rb_threadptr_interrupt(cur->th);
484 rb_bug(
"unexpected THREAD_STOPPED");
487 rb_bug(
"unexpected THREAD_KILLED");
511 err = rb_mutex_unlock_th(mutex, th, GET_EC()->fiber_ptr);
517 #if defined(HAVE_WORKING_FORK)
521 rb_mutex_abandon_all(th->keeping_mutexes);
522 th->keeping_mutexes = NULL;
528 if (th->locking_mutex) {
529 rb_mutex_t *mutex = mutex_ptr(th->locking_mutex);
531 ccan_list_head_init(&mutex->waitq);
532 th->locking_mutex =
Qfalse;
543 mutexes = mutex->next_mutex;
545 mutex->next_mutex = 0;
546 ccan_list_head_init(&mutex->waitq);
552 rb_mutex_sleep_forever(
VALUE self)
554 rb_thread_sleep_deadly_allow_spurious_wakeup(
self,
Qnil, 0);
559 rb_mutex_wait_for(
VALUE time)
561 rb_hrtime_t *rel = (rb_hrtime_t *)time;
563 return RBOOL(sleep_hrtime(GET_THREAD(), *rel, 0));
572 if (!
NIL_P(timeout)) {
577 time_t beg = time(0);
580 if (scheduler !=
Qnil) {
582 mutex_lock_uninterruptible(
self);
585 if (
NIL_P(timeout)) {
586 rb_ensure(rb_mutex_sleep_forever,
self, mutex_lock_uninterruptible,
self);
589 rb_hrtime_t rel = rb_timeval2hrtime(&t);
590 woken =
rb_ensure(rb_mutex_wait_for, (
VALUE)&rel, mutex_lock_uninterruptible,
self);
594 RUBY_VM_CHECK_INTS_BLOCKING(GET_EC());
595 if (!woken)
return Qnil;
596 time_t end = time(0) - beg;
597 return TIMET2NUM(end);
617 mutex_sleep(
int argc,
VALUE *argv,
VALUE self)
648 rb_mutex_synchronize_m(
VALUE self)
658 rb_mutex_allow_trap(
VALUE self,
int val)
670 #define queue_waitq(q) UNALIGNED_MEMBER_PTR(q, waitq)
671 #define queue_list(q) UNALIGNED_MEMBER_PTR(q, que)
672 RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN()
674 struct ccan_list_head waitq;
675 rb_serial_t fork_gen;
678 } RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END();
680 #define szqueue_waitq(sq) UNALIGNED_MEMBER_PTR(sq, q.waitq)
681 #define szqueue_list(sq) UNALIGNED_MEMBER_PTR(sq, q.que)
682 #define szqueue_pushq(sq) UNALIGNED_MEMBER_PTR(sq, pushq)
683 RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN()
686 int num_waiting_push;
687 struct ccan_list_head pushq;
689 } RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END();
692 queue_mark(
void *
ptr)
701 queue_memsize(
const void *
ptr)
709 0, 0, RUBY_TYPED_FREE_IMMEDIATELY|RUBY_TYPED_WB_PROTECTED
713 queue_alloc(
VALUE klass)
719 ccan_list_head_init(queue_waitq(q));
724 queue_fork_check(
struct rb_queue *q)
726 rb_serial_t fork_gen = GET_VM()->fork_gen;
728 if (q->fork_gen == fork_gen) {
732 q->fork_gen = fork_gen;
733 ccan_list_head_init(queue_waitq(q));
749 #define QUEUE_CLOSED FL_USER5
752 queue_timeout2hrtime(
VALUE timeout)
754 if (
NIL_P(timeout)) {
755 return (rb_hrtime_t)0;
759 rel = rb_sec2hrtime(NUM2TIMET(timeout));
764 return rb_hrtime_add(rel, rb_hrtime_now());
768 szqueue_mark(
void *
ptr)
776 szqueue_memsize(
const void *
ptr)
784 0, 0, RUBY_TYPED_FREE_IMMEDIATELY|RUBY_TYPED_WB_PROTECTED
788 szqueue_alloc(
VALUE klass)
792 &szqueue_data_type, sq);
793 ccan_list_head_init(szqueue_waitq(sq));
794 ccan_list_head_init(szqueue_pushq(sq));
799 szqueue_ptr(
VALUE obj)
804 if (queue_fork_check(&sq->q)) {
805 ccan_list_head_init(szqueue_pushq(sq));
806 sq->num_waiting_push = 0;
834 queue_closed_p(
VALUE self)
846 NORETURN(
static void raise_closed_queue_error(
VALUE self));
849 raise_closed_queue_error(
VALUE self)
851 rb_raise(rb_eClosedQueueError,
"queue closed");
922 rb_queue_initialize(
int argc,
VALUE *argv,
VALUE self)
925 struct rb_queue *q = queue_ptr(
self);
926 if ((argc =
rb_scan_args(argc, argv,
"01", &initial)) == 1) {
927 initial = rb_to_array(initial);
930 ccan_list_head_init(queue_waitq(q));
940 if (queue_closed_p(
self)) {
941 raise_closed_queue_error(
self);
944 wakeup_one(queue_waitq(q));
982 rb_queue_close(
VALUE self)
984 struct rb_queue *q = queue_ptr(
self);
986 if (!queue_closed_p(
self)) {
987 FL_SET(
self, QUEUE_CLOSED);
989 wakeup_all(queue_waitq(q));
1003 rb_queue_closed_p(
VALUE self)
1005 return RBOOL(queue_closed_p(
self));
1021 return queue_do_push(
self, queue_ptr(
self), obj);
1025 queue_sleep(
VALUE _args)
1028 rb_thread_sleep_deadly_allow_spurious_wakeup(args->self, args->timeout, args->end);
1041 queue_sleep_done(
VALUE p)
1045 ccan_list_del(&qw->w.node);
1046 qw->as.q->num_waiting--;
1052 szqueue_sleep_done(
VALUE p)
1056 ccan_list_del(&qw->w.node);
1057 qw->as.sq->num_waiting_push--;
1065 check_array(
self, q->que);
1067 if (!should_block) {
1076 rb_hrtime_t end = queue_timeout2hrtime(timeout);
1078 if (queue_closed_p(
self)) {
1079 return queue_closed_result(
self, q);
1088 .w = {.self =
self, .th = ec->thread_ptr, .fiber = nonblocking_fiber(ec->fiber_ptr)},
1092 struct ccan_list_head *waitq = queue_waitq(q);
1104 if (!
NIL_P(timeout) && (rb_hrtime_now() >= end))
1115 return queue_do_pop(
self, queue_ptr(
self), !
RTEST(non_block), timeout);
1126 rb_queue_empty_p(
VALUE self)
1128 return RBOOL(queue_length(
self, queue_ptr(
self)) == 0);
1138 rb_queue_clear(
VALUE self)
1140 struct rb_queue *q = queue_ptr(
self);
1156 rb_queue_length(
VALUE self)
1158 return LONG2NUM(queue_length(
self, queue_ptr(
self)));
1161 NORETURN(
static VALUE rb_queue_freeze(
VALUE self));
1171 rb_queue_freeze(
VALUE self)
1184 rb_queue_num_waiting(
VALUE self)
1186 struct rb_queue *q = queue_ptr(
self);
1188 return INT2NUM(q->num_waiting);
1208 rb_szqueue_initialize(
VALUE self,
VALUE vmax)
1219 ccan_list_head_init(szqueue_waitq(sq));
1220 ccan_list_head_init(szqueue_pushq(sq));
1239 rb_szqueue_close(
VALUE self)
1241 if (!queue_closed_p(
self)) {
1244 FL_SET(
self, QUEUE_CLOSED);
1245 wakeup_all(szqueue_waitq(sq));
1246 wakeup_all(szqueue_pushq(sq));
1258 rb_szqueue_max_get(
VALUE self)
1260 return LONG2NUM(szqueue_ptr(
self)->max);
1280 if (max > sq->max) {
1281 diff = max - sq->max;
1284 sync_wakeup(szqueue_pushq(sq), diff);
1293 if (queue_length(
self, &sq->q) >= sq->max) {
1294 if (
RTEST(non_block)) {
1303 rb_hrtime_t end = queue_timeout2hrtime(timeout);
1304 while (queue_length(
self, &sq->q) >= sq->max) {
1305 if (queue_closed_p(
self)) {
1306 raise_closed_queue_error(
self);
1311 .w = {.self =
self, .th = ec->thread_ptr, .fiber = nonblocking_fiber(ec->fiber_ptr)},
1315 struct ccan_list_head *pushq = szqueue_pushq(sq);
1318 sq->num_waiting_push++;
1326 if (!
NIL_P(timeout) && rb_hrtime_now() >= end) {
1332 return queue_do_push(
self, &sq->q,
object);
1336 szqueue_do_pop(
VALUE self,
int should_block,
VALUE timeout)
1339 VALUE retval = queue_do_pop(
self, &sq->q, should_block, timeout);
1341 if (queue_length(
self, &sq->q) < sq->max) {
1342 wakeup_one(szqueue_pushq(sq));
1350 return szqueue_do_pop(
self, !
RTEST(non_block), timeout);
1360 rb_szqueue_clear(
VALUE self)
1365 wakeup_all(szqueue_pushq(sq));
1379 rb_szqueue_length(
VALUE self)
1383 return LONG2NUM(queue_length(
self, &sq->q));
1393 rb_szqueue_num_waiting(
VALUE self)
1397 return INT2NUM(sq->q.num_waiting + sq->num_waiting_push);
1408 rb_szqueue_empty_p(
VALUE self)
1412 return RBOOL(queue_length(
self, &sq->q) == 0);
1418 struct ccan_list_head waitq;
1419 rb_serial_t fork_gen;
1451 condvar_memsize(
const void *
ptr)
1459 0, 0, RUBY_TYPED_FREE_IMMEDIATELY|RUBY_TYPED_WB_PROTECTED
1463 condvar_ptr(
VALUE self)
1466 rb_serial_t fork_gen = GET_VM()->fork_gen;
1471 if (cv->fork_gen != fork_gen) {
1472 cv->fork_gen = fork_gen;
1473 ccan_list_head_init(&cv->waitq);
1480 condvar_alloc(
VALUE klass)
1486 ccan_list_head_init(&cv->waitq);
1498 rb_condvar_initialize(
VALUE self)
1501 ccan_list_head_init(&cv->waitq);
1513 do_sleep(
VALUE args)
1516 return rb_funcallv(p->mutex, id_sleep, 1, &p->timeout);
1532 rb_condvar_wait(
int argc,
VALUE *argv,
VALUE self)
1539 rb_scan_args(argc, argv,
"11", &args.mutex, &args.timeout);
1543 .th = ec->thread_ptr,
1544 .fiber = nonblocking_fiber(ec->fiber_ptr)
1547 ccan_list_add_tail(&cv->waitq, &
sync_waiter.node);
1558 rb_condvar_signal(
VALUE self)
1561 wakeup_one(&cv->waitq);
1572 rb_condvar_broadcast(
VALUE self)
1575 wakeup_all(&cv->waitq);
1579 NORETURN(
static VALUE undumpable(
VALUE obj));
1582 undumpable(
VALUE obj)
1589 define_thread_class(
VALUE outer,
const ID name,
VALUE super)
1597 Init_thread_sync(
void)
1600 #if defined(TEACH_RDOC) && TEACH_RDOC == 42
1607 #define DEFINE_CLASS(name, super) \
1608 rb_c##name = define_thread_class(rb_cThread, rb_intern(#name), rb_c##super)
1611 DEFINE_CLASS(Mutex, Object);
1623 DEFINE_CLASS(Queue, Object);
1644 DEFINE_CLASS(SizedQueue, Queue);
1654 rb_define_method(rb_cSizedQueue,
"num_waiting", rb_szqueue_num_waiting, 0);
1658 DEFINE_CLASS(ConditionVariable, Object);
1663 rb_define_method(rb_cConditionVariable,
"initialize", rb_condvar_initialize, 0);
1668 rb_define_method(rb_cConditionVariable,
"broadcast", rb_condvar_broadcast, 0);
1673 #include "thread_sync.rbinc"
#define RUBY_ASSERT(...)
Asserts that the given expression is truthy if and only if RUBY_DEBUG is truthy.
std::atomic< unsigned > rb_atomic_t
Type that is eligible for atomic operations.
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
VALUE rb_define_class_id_under(VALUE outer, ID id, VALUE super)
Identical to rb_define_class_under(), except it takes the name in ID instead of C's string.
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
void rb_undef_method(VALUE klass, const char *name)
Defines an undef of a method.
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
Retrieves argument from argc and argv to given VALUE references according to the format string.
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a method.
int rb_block_given_p(void)
Determines if the current method is given a block.
#define FL_UNSET_RAW
Old name of RB_FL_UNSET_RAW.
#define Qundef
Old name of RUBY_Qundef.
#define INT2FIX
Old name of RB_INT2FIX.
#define UNREACHABLE_RETURN
Old name of RBIMPL_UNREACHABLE_RETURN.
#define FL_TEST_RAW
Old name of RB_FL_TEST_RAW.
#define FL_SET
Old name of RB_FL_SET.
#define LONG2NUM
Old name of RB_LONG2NUM.
#define Qtrue
Old name of RUBY_Qtrue.
#define INT2NUM
Old name of RB_INT2NUM.
#define Qnil
Old name of RUBY_Qnil.
#define Qfalse
Old name of RUBY_Qfalse.
#define T_ARRAY
Old name of RUBY_T_ARRAY.
#define NIL_P
Old name of RB_NIL_P.
#define Check_TypedStruct(v, t)
Old name of rb_check_typeddata.
#define NUM2LONG
Old name of RB_NUM2LONG.
#define FIXNUM_P
Old name of RB_FIXNUM_P.
#define FL_SET_RAW
Old name of RB_FL_SET_RAW.
void rb_raise(VALUE exc, const char *fmt,...)
Exception entry point.
int rb_typeddata_is_kind_of(VALUE obj, const rb_data_type_t *data_type)
Checks if the given object is of given kind.
void rb_bug(const char *fmt,...)
Interpreter panic switch.
VALUE rb_eTypeError
TypeError exception.
VALUE rb_eStopIteration
StopIteration exception.
VALUE rb_eArgError
ArgumentError exception.
VALUE rb_ensure(VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*e_proc)(VALUE), VALUE data2)
An equivalent to ensure clause.
VALUE rb_eThreadError
ThreadError exception.
VALUE rb_obj_class(VALUE obj)
Queries the class of an object.
VALUE rb_cThread
Thread class.
double rb_num2dbl(VALUE num)
Converts an instance of rb_cNumeric into C's double.
VALUE rb_equal(VALUE lhs, VALUE rhs)
This function is an optimised version of calling #==.
#define RB_OBJ_WRITE(old, slot, young)
Declaration of a "back" pointer.
VALUE rb_funcallv(VALUE recv, ID mid, int argc, const VALUE *argv)
Identical to rb_funcall(), except it takes the method arguments as a C array.
void rb_gc_mark(VALUE obj)
Marks an object.
Defines RBIMPL_HAS_BUILTIN.
VALUE rb_ary_concat(VALUE lhs, VALUE rhs)
Destructively appends the contents of latter into the end of former.
VALUE rb_ary_shift(VALUE ary)
Destructively deletes an element from the beginning of the passed array and returns what was deleted.
VALUE rb_ary_hidden_new(long capa)
Allocates a hidden (no class) empty array.
VALUE rb_ary_clear(VALUE ary)
Destructively removes everything form an array.
VALUE rb_ary_push(VALUE ary, VALUE elem)
Special case of rb_ary_cat() that it adds only one element.
static int rb_check_arity(int argc, int min, int max)
Ensures that the passed integer is in the passed range.
void rb_provide(const char *feature)
Declares that the given feature is already provided by someone else.
VALUE rb_mutex_new(void)
Creates a mutex.
VALUE rb_mutex_trylock(VALUE mutex)
Attempts to lock the mutex, without waiting for other threads to unlock it.
VALUE rb_mutex_locked_p(VALUE mutex)
Queries if there are any threads that holds the lock.
VALUE rb_mutex_synchronize(VALUE mutex, VALUE(*func)(VALUE arg), VALUE arg)
Obtains the lock, runs the passed function, and releases the lock when it completes.
VALUE rb_mutex_sleep(VALUE self, VALUE timeout)
Releases the lock held in the mutex and waits for the period of time; reacquires the lock on wakeup.
VALUE rb_mutex_unlock(VALUE mutex)
Releases the mutex.
VALUE rb_mutex_lock(VALUE mutex)
Attempts to lock the mutex.
struct timeval rb_time_interval(VALUE num)
Creates a "time interval".
void rb_const_set(VALUE space, ID name, VALUE val)
Names a constant.
void rb_define_alloc_func(VALUE klass, rb_alloc_func_t func)
Sets the allocator function of a class.
ID rb_intern(const char *name)
Finds or creates a symbol of the given name.
char * ptr
Pointer to the underlying memory region, of at least capa bytes.
VALUE rb_yield(VALUE val)
Yields the block.
#define RARRAY_LEN
Just another name of rb_array_len.
#define RUBY_TYPED_DEFAULT_FREE
This is a value you can set to rb_data_type_struct::dfree.
#define TypedData_Get_Struct(obj, type, data_type, sval)
Obtains a C struct from inside of a wrapper Ruby object.
#define TypedData_Make_Struct(klass, type, data_type, sval)
Identical to TypedData_Wrap_Struct, except it allocates a new data region internally instead of takin...
VALUE rb_fiber_scheduler_current(void)
Identical to rb_fiber_scheduler_get(), except it also returns RUBY_Qnil in case of a blocking fiber.
VALUE rb_fiber_scheduler_block(VALUE scheduler, VALUE blocker, VALUE timeout)
Non-blocking wait for the passed "blocker", which is for instance Thread.join or Mutex....
VALUE rb_fiber_scheduler_kernel_sleep(VALUE scheduler, VALUE duration)
Non-blocking sleep.
VALUE rb_fiber_scheduler_unblock(VALUE scheduler, VALUE blocker, VALUE fiber)
Wakes up a fiber previously blocked using rb_fiber_scheduler_block().
#define RTEST
This is an old name of RB_TEST.
This is the struct that holds necessary info for a struct.
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
uintptr_t VALUE
Type that represents a Ruby object.
static bool RB_TYPE_P(VALUE obj, enum ruby_value_type t)
Queries if the given object is of given type.
void ruby_xfree(void *ptr)
Deallocates a storage instance.