Class: Utils::ProbeServer
Defined Under Namespace
Classes: Job
Instance Method Summary collapse
- #clear_jobs ⇒ Object
- #continue ⇒ Object
- #enqueue(job_args) ⇒ Object (also: #run)
-
#initialize ⇒ ProbeServer
constructor
A new instance of ProbeServer.
- #list_jobs ⇒ Object
- #next_job_id ⇒ Object
- #shutdown ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize ⇒ ProbeServer
Returns a new instance of ProbeServer.
24 25 26 27 28 |
# File 'lib/utils/probe_server.rb', line 24 def initialize @jobs_queue = Queue.new @current_job_id = 0 Thread.new { work_loop } end |
Instance Method Details
#clear_jobs ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/utils/probe_server.rb', line 58 def clear_jobs queue_synchronize do unless @jobs_queue.empty? @jobs_queue.clear "Cleared all queued jobs.", :type => :warn true else false end end end |
#continue ⇒ Object
45 46 47 |
# File 'lib/utils/probe_server.rb', line 45 def continue @pid and Process.kill :CONT, @pid end |
#enqueue(job_args) ⇒ Object Also known as: run
34 35 36 37 38 |
# File 'lib/utils/probe_server.rb', line 34 def enqueue(job_args) job = Job.new(self, job_args) "#{job.inspect} enqueued." @jobs_queue.push job end |
#list_jobs ⇒ Object
54 55 56 |
# File 'lib/utils/probe_server.rb', line 54 def list_jobs @jobs_queue.instance_variable_get(:@que) end |
#next_job_id ⇒ Object
30 31 32 |
# File 'lib/utils/probe_server.rb', line 30 def next_job_id @current_job_id += 1 end |
#shutdown ⇒ Object
49 50 51 52 |
# File 'lib/utils/probe_server.rb', line 49 def shutdown "Server was shutdown down – HARD!", :type => :warn exit! 23 end |
#stop ⇒ Object
41 42 43 |
# File 'lib/utils/probe_server.rb', line 41 def stop @pid and Process.kill :STOP, @pid end |