Module: Listen::Internals::ThreadPool

Defined in:
lib/listen/internals/thread_pool.rb

Overview

Just a wrapper for tests to avoid interfereing with Celluloid's threads

Class Method Summary collapse

Class Method Details

.add(&block) ⇒ Object



6
7
8
# File 'lib/listen/internals/thread_pool.rb', line 6

def self.add(&block)
  (@threads ||= Queue.new) << Thread.new { block.call }
end

.stopObject



10
11
12
13
14
15
16
# File 'lib/listen/internals/thread_pool.rb', line 10

def self.stop
  return unless @threads ||= nil

  killed = Queue.new
  killed << @threads.pop.kill until @threads.empty?
  killed.pop.join until killed.empty?
end