Class: DispatchQueue::TimerPool
- Inherits:
-
Object
- Object
- DispatchQueue::TimerPool
- Defined in:
- lib/dispatch_queue_rb/internal/timer_pool.rb
Class Method Summary collapse
Instance Method Summary collapse
- #dispatch_after(eta, group: nil, target_queue: nil, &task) ⇒ Object
-
#initialize ⇒ TimerPool
constructor
A new instance of TimerPool.
Constructor Details
Class Method Details
.default_pool ⇒ Object
13 14 15 |
# File 'lib/dispatch_queue_rb/internal/timer_pool.rb', line 13 def self.default_pool @@default_pool end |
Instance Method Details
#dispatch_after(eta, group: nil, target_queue: nil, &task) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dispatch_queue_rb/internal/timer_pool.rb', line 25 def dispatch_after( eta, group:nil, target_queue:nil, &task ) group.enter() if group target_queue ||= Dispatch.default_queue eta = Time.now + eta if !(Time === eta) continuation = Continuation.new( target_queue:target_queue, group:group, eta:eta, &task ) @mutex.synchronize do @heap.push( continuation ) if @scheduled_eta.nil? || eta < @scheduled_eta @thread = Thread.new { _thread_main() } if @thread.nil? @condition.signal() end end target_queue end |