Class: AutomateEm::ResolverPool

Inherits:
Object
  • Object
show all
Defined in:
lib/automate-em/core/resolver_pool.rb

Instance Method Summary collapse

Constructor Details

#initialize(size = 30) ⇒ ResolverPool

Returns a new instance of ResolverPool.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/automate-em/core/resolver_pool.rb', line 5

def initialize(size = 30)
	
	@size = size
	@jobs = Queue.new
	
	@pool = Array.new(@size) do |i|
		
		Thread.new do
			#Thread.current[:id] = i
			Thread.current.priority = Thread.current.priority - 1
			loop do
				begin
					job = @jobs.pop
					job.resolve
				rescue => e
					#
					# Print error here
					#
				end
			end
		end
		
	end
	
end

Instance Method Details

#schedule(job) ⇒ Object



31
32
33
# File 'lib/automate-em/core/resolver_pool.rb', line 31

def schedule(job)
	@jobs << job
end