Class: Contender::ExecutorService Abstract
- Defined in:
- lib/contender/executor_service.rb
Overview
This class is abstract.
Direct Known Subclasses
Instance Method Summary collapse
- #await_termination(timeout) ⇒ Boolean abstract
- #future_for(task) ⇒ FutureTask
- #invoke_all(tasks) ⇒ Array<FutureTask>
- #shutdown ⇒ undefined abstract
- #shutdown! ⇒ Array abstract
- #shutdown? ⇒ Boolean abstract
- #submit(callable = nil, &block) ⇒ FutureTask
- #terminated? ⇒ Boolean abstract
Methods inherited from Executor
Instance Method Details
#await_termination(timeout) ⇒ Boolean
This method is abstract.
19 20 21 |
# File 'lib/contender/executor_service.rb', line 19 def await_termination(timeout) raise NotImplementedError end |
#future_for(task) ⇒ FutureTask
89 90 91 |
# File 'lib/contender/executor_service.rb', line 89 def future_for(task) FutureTask.new task end |
#invoke_all(tasks) ⇒ Array<FutureTask>
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/contender/executor_service.rb', line 52 def invoke_all(tasks) finished = false futures = Array.new begin tasks.each do |task| future = create_task_for task futures.push future execute future end futures.each do |future| unless future.done? begin future.result rescue CancellationError rescue ExecutionError # The caller can deal with these errors end end end finished = true futures ensure unless finished futures.each do |future| future.cancel true end end end end |
#shutdown ⇒ undefined
This method is abstract.
6 7 8 |
# File 'lib/contender/executor_service.rb', line 6 def shutdown raise NotImplementedError end |
#shutdown! ⇒ Array
This method is abstract.
12 13 14 |
# File 'lib/contender/executor_service.rb', line 12 def shutdown! raise NotImplementedError end |
#shutdown? ⇒ Boolean
This method is abstract.
25 26 27 |
# File 'lib/contender/executor_service.rb', line 25 def shutdown? raise NotImplementedError end |
#submit(callable = nil, &block) ⇒ FutureTask
39 40 41 42 43 44 45 46 47 |
# File 'lib/contender/executor_service.rb', line 39 def submit(callable = nil, &block) callable ||= block raise ArgumentError unless callable future = future_for callable execute future future end |
#terminated? ⇒ Boolean
This method is abstract.
31 32 33 |
# File 'lib/contender/executor_service.rb', line 31 def terminated? raise NotImplementedError end |