diff options
Diffstat (limited to 'ext/monitor/monitor.c')
-rw-r--r-- | ext/monitor/monitor.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/ext/monitor/monitor.c b/ext/monitor/monitor.c index 26a564f4c3..86613f6ade 100644 --- a/ext/monitor/monitor.c +++ b/ext/monitor/monitor.c @@ -53,7 +53,7 @@ monitor_ptr(VALUE monitor) static int mc_owner_p(struct rb_monitor *mc) { - return mc->owner == rb_thread_current(); + return mc->owner == rb_fiber_current(); } static VALUE @@ -65,7 +65,7 @@ monitor_try_enter(VALUE monitor) if (!rb_mutex_trylock(mc->mutex)) { return Qfalse; } - RB_OBJ_WRITE(monitor, &mc->owner, rb_thread_current()); + RB_OBJ_WRITE(monitor, &mc->owner, rb_fiber_current()); mc->count = 0; } mc->count += 1; @@ -78,7 +78,7 @@ monitor_enter(VALUE monitor) struct rb_monitor *mc = monitor_ptr(monitor); if (!mc_owner_p(mc)) { rb_mutex_lock(mc->mutex); - RB_OBJ_WRITE(monitor, &mc->owner, rb_thread_current()); + RB_OBJ_WRITE(monitor, &mc->owner, rb_fiber_current()); mc->count = 0; } mc->count++; @@ -90,7 +90,7 @@ monitor_check_owner(VALUE monitor) { struct rb_monitor *mc = monitor_ptr(monitor); if (!mc_owner_p(mc)) { - rb_raise(rb_eThreadError, "current thread not owner"); + rb_raise(rb_eThreadError, "current fiber not owner"); } return Qnil; } @@ -102,7 +102,7 @@ monitor_exit(VALUE monitor) struct rb_monitor *mc = monitor_ptr(monitor); - if (mc->count <= 0) rb_bug("monitor_exit: count:%d\n", (int)mc->count); + if (mc->count <= 0) rb_bug("monitor_exit: count:%d", (int)mc->count); mc->count--; if (mc->count == 0) { @@ -149,8 +149,8 @@ monitor_wait_for_cond_body(VALUE v) struct wait_for_cond_data *data = (struct wait_for_cond_data *)v; struct rb_monitor *mc = monitor_ptr(data->monitor); // cond.wait(monitor.mutex, timeout) - rb_funcall(data->cond, rb_intern("wait"), 2, mc->mutex, data->timeout); - return Qtrue; + VALUE signaled = rb_funcall(data->cond, rb_intern("wait"), 2, mc->mutex, data->timeout); + return RTEST(signaled) ? Qtrue : Qfalse; } static VALUE @@ -161,7 +161,7 @@ monitor_enter_for_cond(VALUE v) struct wait_for_cond_data *data = (struct wait_for_cond_data *)v; struct rb_monitor *mc = monitor_ptr(data->monitor); - RB_OBJ_WRITE(data->monitor, &mc->owner, rb_thread_current()); + RB_OBJ_WRITE(data->monitor, &mc->owner, rb_fiber_current()); mc->count = NUM2LONG(data->count); return Qnil; } @@ -203,7 +203,7 @@ monitor_synchronize(VALUE monitor) void Init_monitor(void) { -#if HAVE_RB_EXT_RACTOR_SAFE +#ifdef HAVE_RB_EXT_RACTOR_SAFE rb_ext_ractor_safe(true); #endif |