summaryrefslogtreecommitdiff
path: root/test/fiber/scheduler.rb
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2020-09-17 14:30:40 +0200
committerBenoit Daloze <eregontp@gmail.com>2020-09-17 14:30:40 +0200
commit738a089b3ac55e5bfb26f9121ee73ffcb8c4a36b (patch)
tree0fb3bb95dc74207648344e98600a43d3e67b98ae /test/fiber/scheduler.rb
parentc3acfcc78da84002b7dd5000bad21663f0773e2a (diff)
Rename scheduler.{mutex_lock,mutex_unlock} to {block,unblock}
* Move #kernel_sleep next to #block as it is similar
Diffstat (limited to 'test/fiber/scheduler.rb')
-rw-r--r--test/fiber/scheduler.rb27
1 files changed, 15 insertions, 12 deletions
diff --git a/test/fiber/scheduler.rb b/test/fiber/scheduler.rb
index e0b3776306..1e7f60cdf0 100644
--- a/test/fiber/scheduler.rb
+++ b/test/fiber/scheduler.rb
@@ -99,16 +99,6 @@ class Scheduler
Process.clock_gettime(Process::CLOCK_MONOTONIC)
end
- def kernel_sleep(duration = nil)
- if duration
- @waiting[Fiber.current] = current_time + duration
- end
-
- Fiber.yield
-
- return true
- end
-
def io_wait(io, events, duration)
unless (events & IO::READABLE).zero?
@readable[io] = Fiber.current
@@ -123,14 +113,27 @@ class Scheduler
return true
end
- def mutex_lock(mutex)
+ def kernel_sleep(duration = nil)
+ # p [__method__, duration]
+ if duration
+ @waiting[Fiber.current] = current_time + duration
+ end
+
+ Fiber.yield
+
+ return true
+ end
+
+ def block(blocker)
+ # p [__method__, blocker]
@locking += 1
Fiber.yield
ensure
@locking -= 1
end
- def mutex_unlock(mutex, fiber)
+ def unblock(blocker, fiber)
+ # p [__method__, blocker, fiber]
@lock.synchronize do
@ready << fiber
end