diff options
Diffstat (limited to 'lib/rainbows/thread_pool.rb')
-rw-r--r-- | lib/rainbows/thread_pool.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/rainbows/thread_pool.rb b/lib/rainbows/thread_pool.rb index 917b835..3ef719a 100644 --- a/lib/rainbows/thread_pool.rb +++ b/lib/rainbows/thread_pool.rb @@ -67,5 +67,13 @@ module Rainbows end while G.alive end + def join_threads(threads) + G.quit! + threads.delete_if do |thr| + G.tick + thr.alive? ? thr.join(0.01) : true + end until threads.empty? + end + end end |