summaryrefslogtreecommitdiff
path: root/include/ruby
diff options
context:
space:
mode:
authorSamuel Williams <[email protected]>2024-10-31 17:26:37 +1300
committerGitHub <[email protected]>2024-10-31 17:26:37 +1300
commit87fb44dff6409a19d12052cf0fc07ba80a4c45ac (patch)
tree1446cd9390356ae660c50ef7ae877bc57af8d567 /include/ruby
parent550ac2f2edc07d1b63e3755233df0758a652b53f (diff)
Introduce Fiber Scheduler `blocking_region` hook. (#11963)
Notes
Notes: Merged-By: ioquatix <[email protected]>
Diffstat (limited to 'include/ruby')
-rw-r--r--include/ruby/fiber/scheduler.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/ruby/fiber/scheduler.h b/include/ruby/fiber/scheduler.h
index 8f3d383330..bb18b5e01b 100644
--- a/include/ruby/fiber/scheduler.h
+++ b/include/ruby/fiber/scheduler.h
@@ -391,6 +391,26 @@ VALUE rb_fiber_scheduler_io_close(VALUE scheduler, VALUE io);
*/
VALUE rb_fiber_scheduler_address_resolve(VALUE scheduler, VALUE hostname);
+struct rb_fiber_scheduler_blocking_region_state {
+ void *result;
+ int saved_errno;
+};
+
+/**
+ * Defer the execution of the passed function to the scheduler.
+ *
+ * @param[in] scheduler Target scheduler.
+ * @param[in] function The function to run.
+ * @param[in] data The data to pass to the function.
+ * @param[in] unblock_function The unblock function to use to interrupt the operation.
+ * @param[in] data2 The data to pass to the unblock function.
+ * @param[in] flags Flags passed to `rb_nogvl`.
+ * @param[out] state The result and errno of the operation.
+ * @retval RUBY_Qundef `scheduler` doesn't have `#blocking_region`.
+ * @return otherwise What `scheduler.blocking_region` returns.
+ */
+VALUE rb_fiber_scheduler_blocking_region(VALUE scheduler, void* (*function)(void *), void *data, rb_unblock_function_t *unblock_function, void *data2, int flags, struct rb_fiber_scheduler_blocking_region_state *state);
+
/**
* Create and schedule a non-blocking fiber.
*