Class List Method List File List

# Class: Concurrent::SerializedExecutionDelegator

Inherits:
  SimpleDelegator
  - Object
  - SimpleDelegator
  - Concurrent::SerializedExecutionDelegator
  show all
Defined in:
  lib/concurrent/executor/serialized_execution_delegator.rb

## Overview

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

See Also:

- [SimpleDelegator](http://www.ruby-doc.org/stdlib-2.1.2/libdoc/delegate/rdoc/SimpleDelegator.html)
- SerializedExecution

## Instance Method Summary (collapse)

- - (self) <<(task) included from ExecutorService

  Submit a task to the executor for asynchronous processing.

- - (Boolean) can_overflow? included from ExecutorService

  Does the task queue have a maximum size?.

- - (SerializedExecutionDelegator) initialize(executor) constructor

  A new instance of SerializedExecutionDelegator.

- - (undocumented) log(level, progname, message = nil, &block) included from Concern::Logging

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

- - (Boolean) post(*args) { ... }

  Submit a task to the executor for asynchronous processing.

- - (Boolean) serialized? included from SerialExecutorService

  Does this executor guarantee serialization of its operations?.

## Constructor Details

### - (`SerializedExecutionDelegator`) initialize(executor)

Returns a new instance of SerializedExecutionDelegator

    15
    16
    17
    18
    19

    # File 'lib/concurrent/executor/serialized_execution_delegator.rb', line 15

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

## Instance Method Details

### - (`self`) <<(task) Originally defined in module ExecutorService

Submit a task to the executor for asynchronous processing.

Parameters:

- task (`Proc`) —

  the asynchronous task to perform

Returns:

- (`self`) —

  returns itself

### - (`Boolean`) can_overflow? Originally defined in module ExecutorService

Note:

Always returns `false`

Does the task queue have a maximum size?

Returns:

- (`Boolean`) —

  True if the task queue has a maximum size else false.

### - (`undocumented`) log(level, progname, message = nil, &block) Originally defined in module Concern::Logging

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

Parameters:

- level (`Integer`) —

  one of Logger::Severity constants

- progname (`String`) —

  e.g. a path of an Actor

- message (`String`, `nil`) (defaults to: `nil`) —

  when nil block is used to generate the message

Yield Returns:

- (`String`) —

  a message

### - (`Boolean`) post(*args) { ... }

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

    22
    23
    24
    25
    26

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

### - (`Boolean`) serialized? Originally defined in module SerialExecutorService

Note:

Always returns `true`

Does this executor guarantee serialization of its operations?

Returns:

- (`Boolean`) —

  True if the executor guarantees that all operations will be post in the order they are received and no two operations may occur simultaneously. Else false.