Class: Periodico::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/periodico/executor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pool_size:) ⇒ Executor

Returns a new instance of Executor.



5
6
7
# File 'lib/periodico/executor.rb', line 5

def initialize(pool_size:)
  @pool_size = pool_size.to_i
end

Instance Attribute Details

#pool_sizeObject (readonly)

Returns the value of attribute pool_size.



3
4
5
# File 'lib/periodico/executor.rb', line 3

def pool_size
  @pool_size
end

Instance Method Details

#execute(&block) ⇒ Object



9
10
11
# File 'lib/periodico/executor.rb', line 9

def execute(&block)
  sync? ? block.call : worker_pool.post(&block)
end