Class: Concurrent::SerializedExecutionDelegator

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/serialized_execution_delegator.rb

Overview

A wrapper/delegator for any ‘ExecutorService` that guarantees serialized execution of tasks.

Instance Method Summary collapse

Constructor Details

#initialize(executor) ⇒ SerializedExecutionDelegator



15
16
17
18
19
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/serialized_execution_delegator.rb', line 15

def initialize(executor)
  @executor   = executor
  @serializer = SerializedExecution.new
  super(executor)
end

Instance Method Details

#post(*args) { ... } ⇒ Boolean

Submit a task to the executor for asynchronous processing.

Yields:

  • the asynchronous task to perform

Raises:

  • (ArgumentError)

    if no task is given



22
23
24
25
26
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/serialized_execution_delegator.rb', line 22

def post(*args, &task)
  raise ArgumentError.new('no block given') unless block_given?
  return false unless running?
  @serializer.post(@executor, *args, &task)
end