summaryrefslogtreecommitdiff
path: root/thread_sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'thread_sync.c')
-rw-r--r--thread_sync.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/thread_sync.c b/thread_sync.c
index 8295b3d..9932abd 100644
--- a/thread_sync.c
+++ b/thread_sync.c
@@ -32,8 +32,8 @@ sync_wakeup(struct list_head *head, long max)
if (cur->th->status != THREAD_KILLED) {
- if (cur->th->scheduler != Qnil) {
- rb_scheduler_unblock(cur->th->scheduler, cur->self, rb_fiberptr_self(cur->fiber));
+ if (cur->th->scheduler != Qnil && rb_fiberptr_blocking(cur->fiber) == 0) {
+ rb_fiber_scheduler_unblock(cur->th->scheduler, cur->self, rb_fiberptr_self(cur->fiber));
} else {
rb_threadptr_interrupt(cur->th);
cur->th->status = THREAD_RUNNABLE;
@@ -267,8 +267,8 @@ mutex_owned_p(rb_fiber_t *fiber, rb_mutex_t *mutex)
}
}
-static VALUE call_rb_scheduler_block(VALUE mutex) {
- return rb_scheduler_block(rb_scheduler_current(), mutex, Qnil);
+static VALUE call_rb_fiber_scheduler_block(VALUE mutex) {
+ return rb_fiber_scheduler_block(rb_fiber_scheduler_current(), mutex, Qnil);
}
static VALUE
@@ -302,7 +302,7 @@ do_mutex_lock(VALUE self, int interruptible_p)
}
while (mutex->fiber != fiber) {
- VALUE scheduler = rb_scheduler_current();
+ VALUE scheduler = rb_fiber_scheduler_current();
if (scheduler != Qnil) {
COROUTINE_STACK_LOCAL(struct sync_waiter, w);
w->self = self;
@@ -311,7 +311,7 @@ do_mutex_lock(VALUE self, int interruptible_p)
list_add_tail(&mutex->waitq, &w->node);
- rb_ensure(call_rb_scheduler_block, self, delete_from_waitq, (VALUE)w);
+ rb_ensure(call_rb_fiber_scheduler_block, self, delete_from_waitq, (VALUE)w);
if (!mutex->fiber) {
mutex->fiber = fiber;
@@ -437,8 +437,8 @@ rb_mutex_unlock_th(rb_mutex_t *mutex, rb_thread_t *th, rb_fiber_t *fiber)
list_for_each_safe(&mutex->waitq, cur, next, node) {
list_del_init(&cur->node);
- if (cur->th->scheduler != Qnil) {
- rb_scheduler_unblock(cur->th->scheduler, cur->self, rb_fiberptr_self(cur->fiber));
+ if (cur->th->scheduler != Qnil && rb_fiberptr_blocking(cur->fiber) == 0) {
+ rb_fiber_scheduler_unblock(cur->th->scheduler, cur->self, rb_fiberptr_self(cur->fiber));
goto found;
} else {
switch (cur->th->status) {
@@ -545,9 +545,9 @@ rb_mutex_sleep(VALUE self, VALUE timeout)
rb_mutex_unlock(self);
time_t beg = time(0);
- VALUE scheduler = rb_scheduler_current();
+ VALUE scheduler = rb_fiber_scheduler_current();
if (scheduler != Qnil) {
- rb_scheduler_kernel_sleep(scheduler, timeout);
+ rb_fiber_scheduler_kernel_sleep(scheduler, timeout);
mutex_lock_uninterruptible(self);
} else {
if (NIL_P(timeout)) {