Class: OpenHAB::RSpec::Mocks::SynchronousExecutor
- Inherits:
-
Object
- Object
- OpenHAB::RSpec::Mocks::SynchronousExecutor
- Defined in:
- lib/openhab/rspec/mocks/synchronous_executor.rb
Instance Attribute Summary collapse
-
#main_thread ⇒ Object
Returns the value of attribute main_thread.
Instance Method Summary collapse
- #execute(runnable) ⇒ Object
-
#initialize ⇒ SynchronousExecutor
constructor
A new instance of SynchronousExecutor.
- #shutdown ⇒ Object
- #shutdown_now ⇒ Object (also: #shutdownNow)
- #submit(runnable) ⇒ Object
Constructor Details
#initialize ⇒ SynchronousExecutor
Returns a new instance of SynchronousExecutor.
23 24 25 26 |
# File 'lib/openhab/rspec/mocks/synchronous_executor.rb', line 23 def initialize # Allocate a (hopefully) big enough pool size to accommodate scheduled tasks super(10) end |
Instance Attribute Details
#main_thread ⇒ Object
Returns the value of attribute main_thread.
21 22 23 |
# File 'lib/openhab/rspec/mocks/synchronous_executor.rb', line 21 def main_thread @main_thread end |
Instance Method Details
#execute(runnable) ⇒ Object
36 37 38 39 40 |
# File 'lib/openhab/rspec/mocks/synchronous_executor.rb', line 36 def execute(runnable) return super unless Thread.current == main_thread runnable.run end |
#shutdown ⇒ Object
42 |
# File 'lib/openhab/rspec/mocks/synchronous_executor.rb', line 42 def shutdown; end |
#shutdown_now ⇒ Object Also known as: shutdownNow
44 45 46 |
# File 'lib/openhab/rspec/mocks/synchronous_executor.rb', line 44 def shutdown_now [] end |
#submit(runnable) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/openhab/rspec/mocks/synchronous_executor.rb', line 28 def submit(runnable) return super unless Thread.current == main_thread runnable.respond_to?(:run) ? runnable.run : runnable.call java.util.concurrent.CompletableFuture.completed_future(nil) end |