Class: DispatchQueue::SerialQueue
- Inherits:
-
Object
- Object
- DispatchQueue::SerialQueue
- Includes:
- DispatchAfterImpl, DispatchSyncImpl
- Defined in:
- lib/dispatch_queue_rb/serial_queue.rb
Instance Method Summary collapse
- #dispatch_async(group: nil, &task) ⇒ Object (also: #dispatch_barrier_async)
-
#initialize(parent_queue: nil) ⇒ SerialQueue
constructor
A new instance of SerialQueue.
Methods included from DispatchAfterImpl
Methods included from DispatchSyncImpl
#dispatch_barrier_sync, #dispatch_sync
Constructor Details
#initialize(parent_queue: nil) ⇒ SerialQueue
Returns a new instance of SerialQueue.
13 14 15 16 17 18 19 |
# File 'lib/dispatch_queue_rb/serial_queue.rb', line 13 def initialize( parent_queue: nil ) @mutex = Mutex.new @condition = ConditionVariable.new @task_list = [] @active = false @parent_queue = parent_queue || Dispatch.default_queue end |
Instance Method Details
#dispatch_async(group: nil, &task) ⇒ Object Also known as: dispatch_barrier_async
21 22 23 24 25 26 27 28 29 |
# File 'lib/dispatch_queue_rb/serial_queue.rb', line 21 def dispatch_async( group:nil, &task ) group.enter() if group continuation = Continuation.new( target_queue:@parent_queue, group:group ) do _run_task( task ) end continuation.run() if _try_activate_or_enqueue( continuation ) self end |