class MaybeLater::ThreadPool

Public Class Methods

instance() click to toggle source
# File lib/maybe_later/thread_pool.rb, line 3
def self.instance
  @instance ||= new
end
new() click to toggle source

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

# File lib/maybe_later/thread_pool.rb, line 10
def initialize
  @pool = Concurrent::FixedThreadPool.new(MaybeLater.config.max_threads)
  @invokes_callback = InvokesCallback.new
end

Public Instance Methods

run(callback) click to toggle source
# File lib/maybe_later/thread_pool.rb, line 15
def run(callback)
  @pool.post do
    @invokes_callback.call(callback)
  end
end