summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2024-10-31 17:26:37 +1300
committerGitHub <noreply@github.com>2024-10-31 17:26:37 +1300
commit87fb44dff6409a19d12052cf0fc07ba80a4c45ac (patch)
tree1446cd9390356ae660c50ef7ae877bc57af8d567 /thread.c
parent550ac2f2edc07d1b63e3755233df0758a652b53f (diff)
Introduce Fiber Scheduler `blocking_region` hook. (#11963)
Notes
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/thread.c b/thread.c
index 2a937ca278..91278e718d 100644
--- a/thread.c
+++ b/thread.c
@@ -1523,6 +1523,18 @@ rb_nogvl(void *(*func)(void *), void *data1,
rb_unblock_function_t *ubf, void *data2,
int flags)
{
+ VALUE scheduler = rb_fiber_scheduler_current();
+ if (scheduler != Qnil) {
+ struct rb_fiber_scheduler_blocking_region_state state;
+
+ VALUE result = rb_fiber_scheduler_blocking_region(scheduler, func, data1, ubf, data2, flags, &state);
+
+ if (!UNDEF_P(result)) {
+ rb_errno_set(state.saved_errno);
+ return state.result;
+ }
+ }
+
void *val = 0;
rb_execution_context_t *ec = GET_EC();
rb_thread_t *th = rb_ec_thread_ptr(ec);