Class: Doctrine::Runner
- Inherits:
-
Object
- Object
- Doctrine::Runner
- Includes:
- MonitorMixin
- Defined in:
- lib/doctrine/runner.rb
Overview
- public
Instance Method Summary collapse
-
#finished(tenet) ⇒ Object
[public].
-
#initialize(reporter:) ⇒ Runner
constructor
A new instance of Runner.
-
#run(tenet) ⇒ Object
[public].
-
#starting(tenet) ⇒ Object
[public].
-
#wait ⇒ Object
[public].
Constructor Details
#initialize(reporter:) ⇒ Runner
Returns a new instance of Runner.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/doctrine/runner.rb', line 11 def initialize(reporter:) @reporter = reporter @condition = new_cond @queue = Queue.new @worker = Worker.new(queue: @queue, runner: self) @thread = Thread.new { @worker.run } @enqueued = [] @working = [] @finished = [] end |
Instance Method Details
#finished(tenet) ⇒ Object
- public
39 40 41 42 43 44 45 46 47 |
# File 'lib/doctrine/runner.rb', line 39 def finished(tenet) @reporter.finished(tenet) @working.delete(tenet) @finished << tenet synchronize do @condition.signal end end |
#run(tenet) ⇒ Object
- public
24 25 26 27 |
# File 'lib/doctrine/runner.rb', line 24 def run(tenet) @enqueued << tenet @queue << tenet end |
#starting(tenet) ⇒ Object
- public
31 32 33 34 35 |
# File 'lib/doctrine/runner.rb', line 31 def starting(tenet) @reporter.starting(tenet) @enqueued.delete(tenet) @working << tenet end |
#wait ⇒ Object
- public
51 52 53 54 55 56 57 |
# File 'lib/doctrine/runner.rb', line 51 def wait synchronize do @condition.wait_until do @enqueued.empty? && @working.empty? end end end |