Class: MaybeLater::ThreadPool

Inherits:
Object
  • Object
show all
Defined in:
lib/maybe_later/thread_pool.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeThreadPool

The only time this is invoked by the gem will be when an Async task runs As a result, the max thread config will be locked after responding to the first relevant request, since the pool will have been created



10
11
12
13
# File 'lib/maybe_later/thread_pool.rb', line 10

def initialize
  @pool = Concurrent::FixedThreadPool.new(MaybeLater.config.max_threads)
  @invokes_callback = InvokesCallback.new
end

Class Method Details

.instanceObject



3
4
5
# File 'lib/maybe_later/thread_pool.rb', line 3

def self.instance
  @instance ||= new
end

Instance Method Details

#run(callback) ⇒ Object



15
16
17
18
19
# File 'lib/maybe_later/thread_pool.rb', line 15

def run(callback)
  @pool.post do
    @invokes_callback.call(callback)
  end
end