123456789_123456789_123456789_123456789_123456789_

Class: Concurrent::SerializedExecutionDelegator

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, SimpleDelegator
Instance Chain:
Inherits: SimpleDelegator
  • ::Object
Defined in: lib/concurrent-ruby/concurrent/executor/serialized_execution_delegator.rb

Overview

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

Constant Summary

Concern::Logging - Included

SEV_LABEL

Class Method Summary

Instance Attribute Summary

SerialExecutorService - Included

#serialized?

Does this executor guarantee serialization of its operations?

ExecutorService - Included

#can_overflow?

Does the task queue have a maximum size?

#serialized?

Does this executor guarantee serialization of its operations?

Instance Method Summary

ExecutorService - Included

#<<

Submit a task to the executor for asynchronous processing.

#post

Submit a task to the executor for asynchronous processing.

Concern::Logging - Included

#log

Logs through global_logger, it can be overridden by setting @logger.

Constructor Details

.new(executor) ⇒ SerializedExecutionDelegator

[ GitHub ]

  
# File '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.

Parameters:

  • args (Array)

    zero or more arguments to be passed to the task

Yields:

  • the asynchronous task to perform

Returns:

  • (Boolean)

    true if the task is queued, false if the executor is not running

Raises:

  • (ArgumentError)

    if no task is given

[ GitHub ]

  
# File '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