Class: MaybeLater::ThreadPool
- Inherits:
-
Object
- Object
- MaybeLater::ThreadPool
- Defined in:
- lib/maybe_later/thread_pool.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ ThreadPool
constructor
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.
- #run(callable) ⇒ Object
Constructor Details
#initialize ⇒ ThreadPool
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 |
# File 'lib/maybe_later/thread_pool.rb', line 10 def initialize @pool = Concurrent::FixedThreadPool.new(MaybeLater.config.max_threads) end |
Class Method Details
.instance ⇒ Object
3 4 5 |
# File 'lib/maybe_later/thread_pool.rb', line 3 def self.instance @instance ||= new end |
Instance Method Details
#run(callable) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/maybe_later/thread_pool.rb', line 14 def run(callable) @pool.post do callable.call rescue => e MaybeLater.config.on_error&.call(e) end end |