Method: Fairy::Controller#reserve_processor

Defined in:
lib/fairy/controller.rb

#reserve_processor(processor, &block) ⇒ Object

processor methods

reserve してから njob 割り当てを行う



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/fairy/controller.rb', line 339

def reserve_processor(processor, &block)
  @reserves_mutex.synchronize do
	begin
	  return nil unless @reserves[processor]
	rescue DeepConnect::SessionServiceStopped
	  # processor は 終了している可能性がある
	  return nil
	end
	@reserves[processor] += 1
  end
  begin
	yield processor
	processor
  ensure
	@reserves_mutex.synchronize do
	  @reserves[processor] -= 1
	end
  end
end