Skip to content

Commit

Permalink
Added some more methods to runner.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
dbalatero committed Jun 6, 2009
1 parent 557f6d7 commit 53e5601
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/queue_stick/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ class Runner
class MissingPortError < ArgumentError; end
class NumWorkersError < ArgumentError; end

STATUSES = [:booting, :running, :shutting_down]

attr_reader :workers
attr_reader :start_time
attr_reader :status

def initialize(argv, io_stream = STDOUT)
parse_opts!(argv)
validate_opts!
@io = io_stream
@start_time = Time.now.freeze
@status = :booting
end

def run!(worker_klass)
Expand Down Expand Up @@ -56,9 +60,33 @@ def start_workers!
worker.run_loop while true
end
end

@status = :running


@threads.each { |thread| thread.join }
end

def booting?
status == :booting
end

def running?
status == :running
end

def shutting_down?
status == :shutting_down
end

def shutdown!
@status = :shutting_down

@threads.each do |thread|
thread[:shutdown] = true
end
end

private
def parse_opts!(argv)
@options = OpenStruct.new(
Expand Down

0 comments on commit 53e5601

Please sign in to comment.