Class: BackPressure::Executor Abstract
- Inherits:
-
Object
- Object
- BackPressure::Executor
- Defined in:
- lib/back_pressure/executor.rb
Overview
Implementations of ‘BackPressure::Executor` are capable of providing blocking back-pressure to callers using their `execute` or `execute!` methods.
This interface makes no guarantees about how implementations go about controlling back-pressure or the order in which execution will occur in the presence or absence of blocking back-pressure.
Direct Known Subclasses
Instance Method Summary collapse
-
#blocked? ⇒ Boolean
Helper method for determining if any threads are currently blocked by back-pressure.
-
#blocked_threads ⇒ Set{Thread}
Helper method for observing which threads, if any, are blocked at the instant the method is invoked.
-
#execute(blocking_time_limit: nil) ⇒ Boolean
Executes the provided block, after waiting out any back-pressure, returning ‘true` IFF the block was executed.
-
#execute!(blocking_time_limit: nil) ⇒ Object
Executes the provided block, after waiting out any back-pressure, returning the result of the block or raising an ‘ExecutionExpired` exception if the provided limit was reached before execution could begin.
Instance Method Details
#blocked? ⇒ Boolean
This method should be used only for observation-based tooling.
Helper method for determining if any threads are currently blocked by back-pressure.
93 94 95 |
# File 'lib/back_pressure/executor.rb', line 93 def blocked? fail NotImplementedError end |
#blocked_threads ⇒ Set{Thread}
This method should be used only for observation-based tooling.
Helper method for observing which threads, if any, are blocked at the instant the method is invoked. The returned value is a frozen snapshot, and the included threads are not guaranteed to be still blocking by the time they are accessed.
81 82 83 |
# File 'lib/back_pressure/executor.rb', line 81 def blocked_threads fail NotImplementedError end |
#execute(blocking_time_limit: nil) ⇒ Boolean
Executes the provided block, after waiting out any back-pressure, returning ‘true` IFF the block was executed.
48 49 50 |
# File 'lib/back_pressure/executor.rb', line 48 def execute(blocking_time_limit: nil) fail NotImplementedError end |
#execute!(blocking_time_limit: nil) ⇒ Object
Executes the provided block, after waiting out any back-pressure, returning the result of the block or raising an ‘ExecutionExpired` exception if the provided limit was reached before execution could begin.
67 68 69 |
# File 'lib/back_pressure/executor.rb', line 67 def execute!(blocking_time_limit: nil) fail NotImplementedError end |