Introduce Fiber Scheduler blocking_region hook. (#11963)

This commit is contained in:
Samuel Williams 2024-10-31 17:26:37 +13:00 committed by GitHub
parent 550ac2f2ed
commit 87fb44dff6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
Notes: git 2024-10-31 04:26:56 +00:00
Merged-By: ioquatix <samuel@codeotaku.com>
9 changed files with 118 additions and 12 deletions

View file

@ -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);