aboutsummaryrefslogtreecommitdiffstats
path: root/cont.c
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2020-09-05 16:26:24 +1200
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-09-14 16:44:09 +1200
commit178c1b0922dc727897d81d7cfe9c97d5ffa97fd9 (patch)
tree113600e7e6a196b779bcac7529535597858f78a7 /cont.c
parent9e0a48c7a31ecd39be0596d0517b9d521ae75282 (diff)
downloadruby-178c1b0922dc727897d81d7cfe9c97d5ffa97fd9.tar.gz
Make Mutex per-Fiber instead of per-Thread
* Enables Mutex to be used as synchronization between multiple Fibers of the same Thread. * With a Fiber scheduler we can yield to another Fiber on contended Mutex#lock instead of blocking the entire thread. * This also makes the behavior of Mutex consistent across CRuby, JRuby and TruffleRuby. * [Feature #16792]
Diffstat (limited to 'cont.c')
-rw-r--r--cont.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/cont.c b/cont.c
index d228107b9a..0304f4c60e 100644
--- a/cont.c
+++ b/cont.c
@@ -851,6 +851,12 @@ NOINLINE(static VALUE cont_capture(volatile int *volatile stat));
if (!(th)->ec->tag) rb_raise(rb_eThreadError, "not running thread"); \
} while (0)
+rb_thread_t*
+rb_fiber_threadptr(const rb_fiber_t *fiber)
+{
+ return fiber->cont.saved_ec.thread_ptr;
+}
+
static VALUE
cont_thread_value(const rb_context_t *cont)
{
@@ -1146,6 +1152,11 @@ cont_new(VALUE klass)
return cont;
}
+VALUE rb_fiberptr_self(struct rb_fiber_struct *fiber)
+{
+ return fiber->cont.self;
+}
+
void
rb_fiber_init_mjit_cont(struct rb_fiber_struct *fiber)
{