mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
When setting current thread scheduler to nil, invoke #close
.
This commit is contained in:
parent
b6d599d76e
commit
501fff14c7
Notes:
git
2020-09-21 06:52:08 +09:00
7 changed files with 75 additions and 6 deletions
10
thread.c
10
thread.c
|
@ -748,10 +748,7 @@ thread_do_start(rb_thread_t *th)
|
|||
rb_bug("unreachable");
|
||||
}
|
||||
|
||||
VALUE scheduler = th->scheduler;
|
||||
if (scheduler != Qnil) {
|
||||
rb_funcall(scheduler, rb_intern("run"), 0);
|
||||
}
|
||||
rb_thread_scheduler_set(th->self, Qnil);
|
||||
}
|
||||
|
||||
void rb_ec_clear_current_thread_trace_func(const rb_execution_context_t *ec);
|
||||
|
@ -3732,6 +3729,11 @@ rb_thread_scheduler_set(VALUE thread, VALUE scheduler)
|
|||
|
||||
VM_ASSERT(th);
|
||||
|
||||
// We invoke Scheduler#close when setting it to something else, to ensure the previous scheduler runs to completion before changing the scheduler. That way, we do not need to consider interactions, e.g., of a Fiber from the previous scheduler with the new scheduler.
|
||||
if (th->scheduler != Qnil) {
|
||||
rb_scheduler_close(th->scheduler);
|
||||
}
|
||||
|
||||
th->scheduler = scheduler;
|
||||
|
||||
return th->scheduler;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue