Module: Tanker::Http::ThreadPool
- Defined in:
- lib/tanker/core/http.rb
Defined Under Namespace
Modules: ForkHook
Constant Summary collapse
- THREAD_POOL_SIZE =
4
Class Method Summary collapse
Class Method Details
.before_fork ⇒ Object
109 110 111 112 |
# File 'lib/tanker/core/http.rb', line 109 def self.before_fork @http_thread_pool = nil @queue = nil end |
.init ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/tanker/core/http.rb', line 87 def self.init # Queue is a concurrent queue in Ruby @queue = Queue.new @http_thread_pool = THREAD_POOL_SIZE.times do Thread.new do thread_loop end end end |
.push(proc) ⇒ Object
104 105 106 107 |
# File 'lib/tanker/core/http.rb', line 104 def self.push(proc) init if @queue.nil? @queue << proc end |
.thread_loop ⇒ Object
97 98 99 100 101 102 |
# File 'lib/tanker/core/http.rb', line 97 def self.thread_loop loop do work = @queue.pop work.call end end |