diff options
author | Samuel Williams <[email protected]> | 2025-05-23 14:55:05 +0900 |
---|---|---|
committer | GitHub <[email protected]> | 2025-05-23 14:55:05 +0900 |
commit | 73c9d6ccaa2045a011ed991dc29633bd0443971a (patch) | |
tree | 1fe3f91e33e36d98fa280cc7a33ee6295229a232 /include | |
parent | e32054736fcdb2a7729dc770ec0c7ad6a4654135 (diff) |
Allow `IO#close` to interrupt IO operations on fibers using `fiber_interrupt` hook. (#12839)
Notes
Notes:
Merged-By: ioquatix <[email protected]>
Diffstat (limited to 'include')
-rw-r--r-- | include/ruby/fiber/scheduler.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/ruby/fiber/scheduler.h b/include/ruby/fiber/scheduler.h index b678bd0d1a..d0ffb5bd39 100644 --- a/include/ruby/fiber/scheduler.h +++ b/include/ruby/fiber/scheduler.h @@ -199,6 +199,8 @@ VALUE rb_fiber_scheduler_block(VALUE scheduler, VALUE blocker, VALUE timeout); /** * Wakes up a fiber previously blocked using rb_fiber_scheduler_block(). * + * This function may be called from a different thread. + * * @param[in] scheduler Target scheduler. * @param[in] blocker What was awaited for. * @param[in] fiber What to unblock. @@ -412,6 +414,14 @@ struct rb_fiber_scheduler_blocking_operation_state { VALUE rb_fiber_scheduler_blocking_operation_wait(VALUE scheduler, void* (*function)(void *), void *data, rb_unblock_function_t *unblock_function, void *data2, int flags, struct rb_fiber_scheduler_blocking_operation_state *state); /** + * Interrupt a fiber by raising an exception. You can construct an exception using `rb_make_exception`. + * + * This hook may be invoked by a different thread. + * + */ +VALUE rb_fiber_scheduler_fiber_interrupt(VALUE scheduler, VALUE fiber, VALUE exception); + +/** * Create and schedule a non-blocking fiber. * */ |