Module: AsyncMagic
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/async_magic.rb,
lib/async_magic/async.rb,
lib/async_magic/railtie.rb,
lib/async_magic/version.rb
Defined Under Namespace
Modules: ClassMethods
Classes: Railtie
Constant Summary
collapse
- DEFAULT_EXECUTOR_OPTIONS =
{
min_threads: 10,
max_threads: 50,
auto_terminate: true,
idletime: 60, max_queue: 0, fallback_policy: :caller_runs
}.freeze
- THREAD_POOL =
Concurrent::ThreadPoolExecutor.new(DEFAULT_EXECUTOR_OPTIONS)
- ASYNC_LOGGER =
Logger.new($stdout)
- VERSION =
"0.1.0"
Class Method Summary
collapse
Class Method Details
9
10
11
12
|
# File 'lib/async_magic.rb', line 9
def self.configure
yield self
rebuild_executor
end
|
.rebuild_executor ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/async_magic.rb', line 14
def self.rebuild_executor
THREAD_POOL.shutdown
THREAD_POOL.wait_for_termination(5)
AsyncMagic.send(:remove_const, :THREAD_POOL) if AsyncMagic.const_defined?(:THREAD_POOL)
AsyncMagic.const_set(
:THREAD_POOL,
Concurrent::ThreadPoolExecutor.new(executor_options)
)
end
|
.shutdown ⇒ Object
75
76
77
78
|
# File 'lib/async_magic/async.rb', line 75
def self.shutdown
THREAD_POOL.shutdown
THREAD_POOL.wait_for_termination(5) end
|