mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add gvl and fiber assertions to scheduler interface to catch invalid usage.
This commit is contained in:
parent
cb8434563d
commit
b61064b821
Notes:
git
2021-09-20 20:17:06 +09:00
3 changed files with 12 additions and 0 deletions
|
@ -12215,6 +12215,7 @@ scheduler.$(OBJEXT): $(top_srcdir)/internal/gc.h
|
|||
scheduler.$(OBJEXT): $(top_srcdir)/internal/imemo.h
|
||||
scheduler.$(OBJEXT): $(top_srcdir)/internal/serial.h
|
||||
scheduler.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
|
||||
scheduler.$(OBJEXT): $(top_srcdir)/internal/thread.h
|
||||
scheduler.$(OBJEXT): $(top_srcdir)/internal/vm.h
|
||||
scheduler.$(OBJEXT): $(top_srcdir)/internal/warnings.h
|
||||
scheduler.$(OBJEXT): {$(VPATH)}assert.h
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "vm_core.h"
|
||||
#include "ruby/fiber/scheduler.h"
|
||||
#include "ruby/io.h"
|
||||
#include "internal/thread.h"
|
||||
|
||||
static ID id_close;
|
||||
static ID id_scheduler_close;
|
||||
|
@ -51,6 +52,8 @@ Init_Fiber_Scheduler(void)
|
|||
VALUE
|
||||
rb_fiber_scheduler_get(void)
|
||||
{
|
||||
VM_ASSERT(ruby_thread_has_gvl_p());
|
||||
|
||||
rb_thread_t *thread = GET_THREAD();
|
||||
VM_ASSERT(thread);
|
||||
|
||||
|
@ -80,6 +83,8 @@ verify_interface(VALUE scheduler)
|
|||
VALUE
|
||||
rb_fiber_scheduler_set(VALUE scheduler)
|
||||
{
|
||||
VM_ASSERT(ruby_thread_has_gvl_p());
|
||||
|
||||
rb_thread_t *thread = GET_THREAD();
|
||||
VM_ASSERT(thread);
|
||||
|
||||
|
@ -124,6 +129,8 @@ VALUE rb_fiber_scheduler_current_for_thread(VALUE thread)
|
|||
VALUE
|
||||
rb_fiber_scheduler_close(VALUE scheduler)
|
||||
{
|
||||
VM_ASSERT(ruby_thread_has_gvl_p());
|
||||
|
||||
VALUE result;
|
||||
|
||||
result = rb_check_funcall(scheduler, id_scheduler_close, 0, NULL);
|
||||
|
@ -194,6 +201,8 @@ rb_fiber_scheduler_block(VALUE scheduler, VALUE blocker, VALUE timeout)
|
|||
VALUE
|
||||
rb_fiber_scheduler_unblock(VALUE scheduler, VALUE blocker, VALUE fiber)
|
||||
{
|
||||
VM_ASSERT(rb_obj_is_fiber(fiber));
|
||||
|
||||
return rb_funcall(scheduler, id_unblock, 2, blocker, fiber);
|
||||
}
|
||||
|
||||
|
|
|
@ -645,6 +645,8 @@ rb_check_funcall(VALUE recv, ID mid, int argc, const VALUE *argv)
|
|||
static VALUE
|
||||
rb_check_funcall_default_kw(VALUE recv, ID mid, int argc, const VALUE *argv, VALUE def, int kw_splat)
|
||||
{
|
||||
VM_ASSERT(ruby_thread_has_gvl_p());
|
||||
|
||||
VALUE klass = CLASS_OF(recv);
|
||||
const rb_callable_method_entry_t *me;
|
||||
rb_execution_context_t *ec = GET_EC();
|
||||
|
|
Loading…
Reference in a new issue