Class: Concurrent::IndirectImmediateExecutor
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
Concurrent::ImmediateExecutor
|
Defined in: | lib/concurrent-ruby/concurrent/executor/indirect_immediate_executor.rb |
Overview
Intended for use primarily in testing and debugging.
An executor service which runs all operations on a new thread, blocking until it completes. Operations are performed in the order they are received and no two operations can be performed simultaneously.
This executor service exists mainly for testing an debugging. When used it immediately runs every #post operation on a new thread, blocking the current thread until the operation is complete. This is similar to how the ImmediateExecutor
works, but the operation has the full stack of the new thread at its disposal. This can be helpful when the operations will spawn more operations on the same executor and so on - such a situation might overflow the single stack in case of an ImmediateExecutor
, which is inconsistent with how it would behave for a threaded executor.
Constant Summary
Class Method Summary
-
.new ⇒ IndirectImmediateExecutor
constructor
Creates a new executor.
ImmediateExecutor
- Inherited
.new | Creates a new executor. |
AbstractExecutorService
- Inherited
.new | Create a new thread pool. |
Instance Attribute Summary
ImmediateExecutor
- Inherited
#running? | Is the executor running? |
#shutdown? | Is the executor shutdown? |
#shuttingdown? | Is the executor shuttingdown? |
SerialExecutorService
- Included
#serialized? | Does this executor guarantee serialization of its operations? |
AbstractExecutorService
- Inherited
#auto_terminate= |
|
#auto_terminate? | Is the executor auto-terminate when the application exits? |
#fallback_policy, #name, | |
#running? | Is the executor running? |
#shutdown | Begin an orderly shutdown. |
#shutdown? | Is the executor shutdown? |
#shuttingdown? | Is the executor shuttingdown? |
#ns_auto_terminate? |
ExecutorService
- Included
#can_overflow? | Does the task queue have a maximum size? |
#serialized? | Does this executor guarantee serialization of its operations? |
Instance Method Summary
-
#post(*args) { ... } ⇒ Boolean
Submit a task to the executor for asynchronous processing.
ImmediateExecutor
- Inherited
#<< | Submit a task to the executor for asynchronous processing. |
#kill | Alias for ImmediateExecutor#shutdown. |
#post | Submit a task to the executor for asynchronous processing. |
#shutdown | Begin an orderly shutdown. |
#wait_for_termination | Block until executor shutdown is complete or until |
AbstractExecutorService
- Inherited
#<< | Submit a task to the executor for asynchronous processing. |
#can_overflow? | Does the task queue have a maximum size? |
#kill | Begin an immediate shutdown. |
#post | Submit a task to the executor for asynchronous processing. |
#serialized? | Does this executor guarantee serialization of its operations? |
#to_s, | |
#wait_for_termination | Block until executor shutdown is complete or until |
#fallback_action | Returns an action which executes the |
#ns_execute, | |
#ns_kill_execution | Callback method called when the executor has been killed. |
#ns_shutdown_execution | Callback method called when an orderly shutdown has completed. |
Concern::Deprecation
- Included
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. |
Synchronization::LockableObject
- Inherited
Constructor Details
.new ⇒ IndirectImmediateExecutor
Creates a new executor
# File 'lib/concurrent-ruby/concurrent/executor/indirect_immediate_executor.rb', line 21
def initialize super @internal_executor = SimpleExecutorService.new end
Instance Method Details
#post(*args) { ... } ⇒ Boolean
Submit a task to the executor for asynchronous processing.
# File 'lib/concurrent-ruby/concurrent/executor/indirect_immediate_executor.rb', line 27
def post(*args, &task) raise ArgumentError.new("no block given") unless block_given? return false unless running? event = Concurrent::Event.new @internal_executor.post do begin task.call(*args) ensure event.set end end event.wait true end