Class: ConcurrentWorker::WorkerPool::ReadyWorkerQueue

Inherits:
Queue
  • Object
show all
Defined in:
lib/concurrent_worker/workerpool.rb

Instance Method Summary collapse

Constructor Details

#initializeReadyWorkerQueue

Returns a new instance of ReadyWorkerQueue.



6
7
8
9
# File 'lib/concurrent_worker/workerpool.rb', line 6

def initialize
  super()
  @m = Mutex.new
end

Instance Method Details

#popObject



15
16
17
18
19
20
21
22
# File 'lib/concurrent_worker/workerpool.rb', line 15

def pop
  @m.synchronize do
    queued = []
    queued.push(super_pop) until empty?
    queued.sort_by{ |w| w.req_counter.size }.each{ |w| super_push(w) }
  end
  super_pop
end

#push(arg) ⇒ Object



10
11
12
13
14
# File 'lib/concurrent_worker/workerpool.rb', line 10

def push(arg)
  @m.synchronize do
    super_push(arg)
  end
end

#super_popObject



5
# File 'lib/concurrent_worker/workerpool.rb', line 5

alias :super_pop  :pop

#super_pushObject



4
# File 'lib/concurrent_worker/workerpool.rb', line 4

alias :super_push :push