Class: Julewire::Ractor::ReplyTimeoutScheduler
- Inherits:
-
Object
- Object
- Julewire::Ractor::ReplyTimeoutScheduler
- Defined in:
- lib/julewire/ractor/reply_timeout_scheduler.rb
Constant Summary collapse
- THREAD_NAME =
"julewire-ractor-reply-timeout"
Instance Method Summary collapse
- #cancel(token) ⇒ Object
-
#initialize(timeout_value:) ⇒ ReplyTimeoutScheduler
constructor
This stays stdlib-only because RemoteRuntime creates it inside a Ractor.
- #schedule(reply, timeout:) ⇒ Object
Constructor Details
#initialize(timeout_value:) ⇒ ReplyTimeoutScheduler
This stays stdlib-only because RemoteRuntime creates it inside a Ractor. Concurrent::ScheduledTask currently touches non-shareable concurrent-ruby constants from worker ractors.
12 13 14 15 |
# File 'lib/julewire/ractor/reply_timeout_scheduler.rb', line 12 def initialize(timeout_value:) @timeout_value = timeout_value @scheduler = Core::Scheduling::DeadlineScheduler.new(thread_name: THREAD_NAME, idle: :exit) end |
Instance Method Details
#cancel(token) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/julewire/ractor/reply_timeout_scheduler.rb', line 21 def cancel(token) return unless token @scheduler.cancel(token) rescue StandardError nil end |
#schedule(reply, timeout:) ⇒ Object
17 18 19 |
# File 'lib/julewire/ractor/reply_timeout_scheduler.rb', line 17 def schedule(reply, timeout:) @scheduler.schedule(timeout) { send_timeout(reply) } end |