Class: Phronomy::Runtime::TimerService Private
- Inherits:
-
Object
- Object
- Phronomy::Runtime::TimerService
- Defined in:
- lib/phronomy/runtime/timer_service.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Lazy-initialised timer service for a Phronomy::Runtime instance.
Returns a SchedulerTimerAdapter when the backing scheduler is a
DeterministicScheduler (enabling virtual-time integration for the
:fiber backend), or a standard TimerQueue (OS-thread backed) for all
other schedulers.
Instance Method Summary collapse
-
#initialize(scheduler) ⇒ TimerService
constructor
private
A new instance of TimerService.
-
#shutdown ⇒ void
private
Shuts down the timer queue if it was started.
-
#timer_queue ⇒ TimerQueue, SchedulerTimerAdapter
private
Returns (or lazily creates) the timer queue for this runtime.
Constructor Details
#initialize(scheduler) ⇒ TimerService
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of TimerService.
15 16 17 18 19 |
# File 'lib/phronomy/runtime/timer_service.rb', line 15 def initialize(scheduler) @scheduler = scheduler @mutex = Mutex.new @timer = nil end |
Instance Method Details
#shutdown ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Shuts down the timer queue if it was started.
37 38 39 |
# File 'lib/phronomy/runtime/timer_service.rb', line 37 def shutdown @mutex.synchronize { @timer&.shutdown } end |
#timer_queue ⇒ TimerQueue, SchedulerTimerAdapter
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns (or lazily creates) the timer queue for this runtime.
24 25 26 27 28 29 30 31 32 |
# File 'lib/phronomy/runtime/timer_service.rb', line 24 def timer_queue @mutex.synchronize do @timer ||= if @scheduler.is_a?(DeterministicScheduler) SchedulerTimerAdapter.new(@scheduler) else TimerQueue.new end end end |