Method: ZK::Threadpool#shutdown

Defined in:
lib/zk/threadpool.rb

#shutdown(timeout = 2) ⇒ Object

join all threads in this threadpool, they will be given a maximum of +timeout+ seconds to exit before they are considered hung and will be ignored (this is an issue with threads in general: see http://blog.headius.com/2008/02/rubys-threadraise-threadkill-timeoutrb.html for more info)

the default timeout is 2 seconds per thread



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/zk/threadpool.rb', line 169

def shutdown(timeout=2)
  threads = nil

  @mutex.lock
  begin
    return false if @state == :shutdown
    @state = :shutdown

    @queue.clear
    threads, @threadpool = @threadpool, []
    @cond.broadcast
  ensure
    @mutex.unlock rescue nil
  end

  join_all(threads)

  nil
end