ruby-changes:65200
From: Samuel <ko1@a...>
Date: Tue, 9 Feb 2021 15:40:22 +0900 (JST)
Subject: [ruby-changes:65200] 5f69a7f604 (master): Expose scheduler as public interface & bug fixes. (#3945)
https://git.ruby-lang.org/ruby.git/commit/?id=5f69a7f604 From 5f69a7f60467fa58c2f998daffab43e118bff36c Mon Sep 17 00:00:00 2001 From: Samuel Williams <samuel.williams@o...> Date: Tue, 9 Feb 2021 19:39:56 +1300 Subject: Expose scheduler as public interface & bug fixes. (#3945) * Rename `rb_scheduler` to `rb_fiber_scheduler`. * Use public interface if available. * Use `rb_check_funcall` where possible. * Don't use `unblock` unless the fiber was non-blocking. --- common.mk | 20 +++-- cont.c | 15 ++-- eval.c | 8 +- ext/io/console/console.c | 7 +- ext/io/console/extconf.rb | 2 +- ext/psych/depend | 185 +++++++++++++++++++++++++---------------- include/ruby/fiber/scheduler.h | 40 +++++++++ inits.c | 2 +- internal/cont.h | 1 + internal/scheduler.h | 44 ---------- io.c | 62 +++++++------- process.c | 13 ++- scheduler.c | 84 +++++++++---------- test/fiber/http.rb | 11 +-- test/fiber/scheduler.rb | 24 +++++- test/fiber/test_thread.rb | 45 ++++++++++ thread.c | 16 ++-- thread_sync.c | 20 ++--- 18 files changed, 355 insertions(+), 244 deletions(-) create mode 100644 include/ruby/fiber/scheduler.h delete mode 100644 internal/scheduler.h create mode 100644 test/fiber/test_thread.rb diff --git a/common.mk b/common.mk index 810530c..1a3de30 100644 --- a/common.mk +++ b/common.mk @@ -3196,13 +3196,13 @@ cont.$(OBJEXT): $(CCAN_DIR)/list/list.h https://github.com/ruby/ruby/blob/trunk/common.mk#L3196 cont.$(OBJEXT): $(CCAN_DIR)/str/str.h cont.$(OBJEXT): $(hdrdir)/ruby.h cont.$(OBJEXT): $(hdrdir)/ruby/ruby.h +cont.$(OBJEXT): $(top_srcdir)/include/ruby/fiber/scheduler.h cont.$(OBJEXT): $(top_srcdir)/internal/array.h cont.$(OBJEXT): $(top_srcdir)/internal/compilers.h cont.$(OBJEXT): $(top_srcdir)/internal/cont.h cont.$(OBJEXT): $(top_srcdir)/internal/gc.h cont.$(OBJEXT): $(top_srcdir)/internal/imemo.h cont.$(OBJEXT): $(top_srcdir)/internal/proc.h -cont.$(OBJEXT): $(top_srcdir)/internal/scheduler.h cont.$(OBJEXT): $(top_srcdir)/internal/serial.h cont.$(OBJEXT): $(top_srcdir)/internal/static_assert.h cont.$(OBJEXT): $(top_srcdir)/internal/vm.h @@ -3224,6 +3224,7 @@ cont.$(OBJEXT): {$(VPATH)}cont.c https://github.com/ruby/ruby/blob/trunk/common.mk#L3224 cont.$(OBJEXT): {$(VPATH)}debug_counter.h cont.$(OBJEXT): {$(VPATH)}defines.h cont.$(OBJEXT): {$(VPATH)}eval_intern.h +cont.$(OBJEXT): {$(VPATH)}fiber/scheduler.h cont.$(OBJEXT): {$(VPATH)}gc.h cont.$(OBJEXT): {$(VPATH)}id.h cont.$(OBJEXT): {$(VPATH)}id_table.h @@ -5215,6 +5216,7 @@ eval.$(OBJEXT): $(CCAN_DIR)/list/list.h https://github.com/ruby/ruby/blob/trunk/common.mk#L5216 eval.$(OBJEXT): $(CCAN_DIR)/str/str.h eval.$(OBJEXT): $(hdrdir)/ruby.h eval.$(OBJEXT): $(hdrdir)/ruby/ruby.h +eval.$(OBJEXT): $(top_srcdir)/include/ruby/fiber/scheduler.h eval.$(OBJEXT): $(top_srcdir)/internal/array.h eval.$(OBJEXT): $(top_srcdir)/internal/class.h eval.$(OBJEXT): $(top_srcdir)/internal/compilers.h @@ -5226,7 +5228,6 @@ eval.$(OBJEXT): $(top_srcdir)/internal/imemo.h https://github.com/ruby/ruby/blob/trunk/common.mk#L5228 eval.$(OBJEXT): $(top_srcdir)/internal/inits.h eval.$(OBJEXT): $(top_srcdir)/internal/io.h eval.$(OBJEXT): $(top_srcdir)/internal/object.h -eval.$(OBJEXT): $(top_srcdir)/internal/scheduler.h eval.$(OBJEXT): $(top_srcdir)/internal/serial.h eval.$(OBJEXT): $(top_srcdir)/internal/static_assert.h eval.$(OBJEXT): $(top_srcdir)/internal/string.h @@ -5254,6 +5255,7 @@ eval.$(OBJEXT): {$(VPATH)}eval.c https://github.com/ruby/ruby/blob/trunk/common.mk#L5255 eval.$(OBJEXT): {$(VPATH)}eval_error.c eval.$(OBJEXT): {$(VPATH)}eval_intern.h eval.$(OBJEXT): {$(VPATH)}eval_jump.c +eval.$(OBJEXT): {$(VPATH)}fiber/scheduler.h eval.$(OBJEXT): {$(VPATH)}gc.h eval.$(OBJEXT): {$(VPATH)}id.h eval.$(OBJEXT): {$(VPATH)}id_table.h @@ -6562,6 +6564,7 @@ io.$(OBJEXT): $(CCAN_DIR)/list/list.h https://github.com/ruby/ruby/blob/trunk/common.mk#L6564 io.$(OBJEXT): $(CCAN_DIR)/str/str.h io.$(OBJEXT): $(hdrdir)/ruby.h io.$(OBJEXT): $(hdrdir)/ruby/ruby.h +io.$(OBJEXT): $(top_srcdir)/include/ruby/fiber/scheduler.h io.$(OBJEXT): $(top_srcdir)/internal/array.h io.$(OBJEXT): $(top_srcdir)/internal/bignum.h io.$(OBJEXT): $(top_srcdir)/internal/bits.h @@ -6577,7 +6580,6 @@ io.$(OBJEXT): $(top_srcdir)/internal/io.h https://github.com/ruby/ruby/blob/trunk/common.mk#L6580 io.$(OBJEXT): $(top_srcdir)/internal/numeric.h io.$(OBJEXT): $(top_srcdir)/internal/object.h io.$(OBJEXT): $(top_srcdir)/internal/process.h -io.$(OBJEXT): $(top_srcdir)/internal/scheduler.h io.$(OBJEXT): $(top_srcdir)/internal/serial.h io.$(OBJEXT): $(top_srcdir)/internal/static_assert.h io.$(OBJEXT): $(top_srcdir)/internal/string.h @@ -6604,6 +6606,7 @@ io.$(OBJEXT): {$(VPATH)}defines.h https://github.com/ruby/ruby/blob/trunk/common.mk#L6606 io.$(OBJEXT): {$(VPATH)}dln.h io.$(OBJEXT): {$(VPATH)}encindex.h io.$(OBJEXT): {$(VPATH)}encoding.h +io.$(OBJEXT): {$(VPATH)}fiber/scheduler.h io.$(OBJEXT): {$(VPATH)}id.h io.$(OBJEXT): {$(VPATH)}id_table.h io.$(OBJEXT): {$(VPATH)}intern.h @@ -10017,6 +10020,7 @@ process.$(OBJEXT): $(CCAN_DIR)/list/list.h https://github.com/ruby/ruby/blob/trunk/common.mk#L10020 process.$(OBJEXT): $(CCAN_DIR)/str/str.h process.$(OBJEXT): $(hdrdir)/ruby.h process.$(OBJEXT): $(hdrdir)/ruby/ruby.h +process.$(OBJEXT): $(top_srcdir)/include/ruby/fiber/scheduler.h process.$(OBJEXT): $(top_srcdir)/internal/array.h process.$(OBJEXT): $(top_srcdir)/internal/bits.h process.$(OBJEXT): $(top_srcdir)/internal/class.h @@ -10029,7 +10033,6 @@ process.$(OBJEXT): $(top_srcdir)/internal/hash.h https://github.com/ruby/ruby/blob/trunk/common.mk#L10033 process.$(OBJEXT): $(top_srcdir)/internal/imemo.h process.$(OBJEXT): $(top_srcdir)/internal/object.h process.$(OBJEXT): $(top_srcdir)/internal/process.h -process.$(OBJEXT): $(top_srcdir)/internal/scheduler.h process.$(OBJEXT): $(top_srcdir)/internal/serial.h process.$(OBJEXT): $(top_srcdir)/internal/static_assert.h process.$(OBJEXT): $(top_srcdir)/internal/string.h @@ -10055,6 +10058,7 @@ process.$(OBJEXT): {$(VPATH)}debug_counter.h https://github.com/ruby/ruby/blob/trunk/common.mk#L10058 process.$(OBJEXT): {$(VPATH)}defines.h process.$(OBJEXT): {$(VPATH)}dln.h process.$(OBJEXT): {$(VPATH)}encoding.h +process.$(OBJEXT): {$(VPATH)}fiber/scheduler.h process.$(OBJEXT): {$(VPATH)}hrtime.h process.$(OBJEXT): {$(VPATH)}id.h process.$(OBJEXT): {$(VPATH)}id_table.h @@ -12357,11 +12361,11 @@ scheduler.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h https://github.com/ruby/ruby/blob/trunk/common.mk#L12361 scheduler.$(OBJEXT): $(CCAN_DIR)/list/list.h scheduler.$(OBJEXT): $(CCAN_DIR)/str/str.h scheduler.$(OBJEXT): $(hdrdir)/ruby/ruby.h +scheduler.$(OBJEXT): $(top_srcdir)/include/ruby/fiber/scheduler.h scheduler.$(OBJEXT): $(top_srcdir)/internal/array.h scheduler.$(OBJEXT): $(top_srcdir)/internal/compilers.h scheduler.$(OBJEXT): $(top_srcdir)/internal/gc.h scheduler.$(OBJEXT): $(top_srcdir)/internal/imemo.h -scheduler.$(OBJEXT): $(top_srcdir)/internal/scheduler.h scheduler.$(OBJEXT): $(top_srcdir)/internal/serial.h scheduler.$(OBJEXT): $(top_srcdir)/internal/static_assert.h scheduler.$(OBJEXT): $(top_srcdir)/internal/vm.h @@ -12380,7 +12384,9 @@ scheduler.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h https://github.com/ruby/ruby/blob/trunk/common.mk#L12384 scheduler.$(OBJEXT): {$(VPATH)}config.h scheduler.$(OBJEXT): {$(VPATH)}defines.h scheduler.$(OBJEXT): {$(VPATH)}encoding.h +scheduler.$(OBJEXT): {$(VPATH)}fiber/scheduler.h scheduler.$(OBJEXT): {$(VPATH)}id.h +scheduler.$(OBJEXT): {$(VPATH)}include/ruby/fiber/scheduler.h scheduler.$(OBJEXT): {$(VPATH)}intern.h scheduler.$(OBJEXT): {$(VPATH)}internal.h scheduler.$(OBJEXT): {$(VPATH)}internal/anyargs.h @@ -12512,7 +12518,6 @@ scheduler.$(OBJEXT): {$(VPATH)}internal/module.h https://github.com/ruby/ruby/blob/trunk/common.mk#L12518 scheduler.$(OBJEXT): {$(VPATH)}internal/newobj.h scheduler.$(OBJEXT): {$(VPATH)}internal/rgengc.h scheduler.$(OBJEXT): {$(VPATH)}internal/scan_args.h -scheduler.$(OBJEXT): {$(VPATH)}internal/scheduler.h scheduler.$(OBJEXT): {$(VPATH)}internal/special_consts.h scheduler.$(OBJEXT): {$(VPATH)}internal/static_assert.h scheduler.$(OBJEXT): {$(VPATH)}internal/stdalign.h @@ -14034,6 +14039,7 @@ thread.$(OBJEXT): $(CCAN_DIR)/list/list.h https://github.com/ruby/ruby/blob/trunk/common.mk#L14039 thread.$(OBJEXT): $(CCAN_DIR)/str/str.h thread.$(OBJEXT): $(hdrdir)/ruby.h thread.$(OBJEXT): $(hdrdir)/ruby/ruby.h +thread.$(OBJEXT): $(top_srcdir)/include/ruby/fiber/scheduler.h thread.$(OBJEXT): $(top_srcdir)/internal/array.h thread.$(OBJEXT): $(top_srcdir)/internal/bits.h thread.$(OBJEXT): $(top_srcdir)/internal/class.h @@ -14046,7 +14052,6 @@ thread.$(OBJEXT): $(top_srcdir)/internal/imemo.h https://github.com/ruby/ruby/blob/trunk/common.mk#L14052 thread.$(OBJEXT): $(top_srcdir)/internal/io.h thread.$(OBJEXT): $(top_srcdir)/internal/object.h thread.$(OBJEXT): $(top_srcdir)/internal/proc.h -thread.$(OBJEXT): $(top_srcdir)/internal/scheduler.h thread.$(OBJEXT): $(top_srcdir)/internal/serial.h thread.$(OBJEXT): $(top_srcdir)/internal/signal.h thread.$(OBJEXT): $(top_srcdir)/internal/static_assert.h @@ -14073,6 +14078,7 @@ thread.$(OBJEXT): {$(VPATH)}debug_counter.h https://github.com/ruby/ruby/blob/trunk/common.mk#L14078 thread.$(OBJEXT): {$(VPATH)}defines.h thread.$(OBJEXT): {$(VPATH)}encoding.h thread.$(OBJEXT): {$(VPATH)}eval_intern.h +thread.$(OBJEXT): {$(VPATH)}fiber/scheduler.h thread.$(OBJEXT): {$(VPATH)}gc.h thread.$(OBJEXT): {$(VPATH)}hrtime.h thread.$(OBJEXT): {$(VPATH)}id.h diff --git a/cont.c b/cont.c index 694c2d9..abd6a2f 100644 --- a/cont.c +++ b/cont.c @@ -24,7 +24,7 @@ https://github.com/ruby/ruby/blob/trunk/cont.c#L24 #include "internal/cont.h" #include "internal/p (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/