Class: Concurrent::ImmediateExecutor
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
Concurrent::AbstractExecutorService
|
Defined in: | lib/concurrent-ruby/concurrent/executor/immediate_executor.rb |
Overview
Intended for use primarily in testing and debugging.
An executor service which runs all operations on the current thread, blocking as necessary. 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 the current thread, blocking that thread until the operation is complete. This can be very beneficial during testing because it makes all operations deterministic.
Constant Summary
Class Method Summary
-
.new ⇒ ImmediateExecutor
constructor
Creates a new executor.
AbstractExecutorService
- Inherited
.new | Create a new thread pool. |
Instance Attribute Summary
-
#running? ⇒ Boolean
readonly
Is the executor running?
-
#shutdown? ⇒ Boolean
readonly
Is the executor shutdown?
-
#shuttingdown? ⇒ Boolean
readonly
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
-
#<<(task) ⇒ self
Submit a task to the executor for asynchronous processing.
-
#kill
Alias for #shutdown.
-
#post(*args) { ... } ⇒ Boolean
Submit a task to the executor for asynchronous processing.
-
#shutdown
(also: #kill)
readonly
Begin an orderly shutdown.
-
#wait_for_termination(timeout = nil) ⇒ Boolean
Block until executor shutdown is complete or until
timeout
seconds have passed.
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 ⇒ ImmediateExecutor
Creates a new executor
# File 'lib/concurrent-ruby/concurrent/executor/immediate_executor.rb', line 21
def initialize @stopped = Concurrent::Event.new end
Instance Attribute Details
#running? ⇒ Boolean
(readonly)
Is the executor running?
# File 'lib/concurrent-ruby/concurrent/executor/immediate_executor.rb', line 40
def running? ! shutdown? end
#shutdown? ⇒ Boolean
(readonly)
Is the executor shutdown?
# File 'lib/concurrent-ruby/concurrent/executor/immediate_executor.rb', line 50
def shutdown? @stopped.set? end
#shuttingdown? ⇒ Boolean
(readonly)
Is the executor shuttingdown?
# File 'lib/concurrent-ruby/concurrent/executor/immediate_executor.rb', line 45
def shuttingdown? false end
Instance Method Details
#<<(task) ⇒ self
Submit a task to the executor for asynchronous processing.
# File 'lib/concurrent-ruby/concurrent/executor/immediate_executor.rb', line 34
def <<(task) post(&task) self end
#kill
Alias for #shutdown.
# File 'lib/concurrent-ruby/concurrent/executor/immediate_executor.rb', line 59
alias_method :kill, :shutdown
#post(*args) { ... } ⇒ Boolean
Submit a task to the executor for asynchronous processing.
#shutdown (readonly) Also known as: #kill
Begin an orderly shutdown. Tasks already in the queue will be executed, but no new tasks will be accepted. Has no additional effect if the thread pool is not running.
# File 'lib/concurrent-ruby/concurrent/executor/immediate_executor.rb', line 55
def shutdown @stopped.set true end
#wait_for_termination(timeout = nil) ⇒ Boolean
# File 'lib/concurrent-ruby/concurrent/executor/immediate_executor.rb', line 62
def wait_for_termination(timeout = nil) @stopped.wait(timeout) end