/
githubmirror
/
device-mapper-test-suite
Обзор
Документация
Войти
/
githubmirror
/
device-mapper-test-suite
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
lib/dmtest/thread-utils.rb
33 строки
615 B
Joe Thornber
Import from thinp-test-suite
04 июн 2013, 15:42
04 июн 2013, 15:42
95f98f8
Код
Авторство
О чём код?
require 'thread' #---------------------------------------------------------------- class ThreadedJobs def initialize @stop_requested = false @lock = Mutex.new @tids = Array.new end def add_job(count, *args, &block) count.times do @tids << Thread.new(*args) do |*args| until @lock.synchronize {@stop_requested} do block.call(*args) end end end end def stop @lock.synchronize do @stop_requested = true end @tids.each do |tid| tid.join end end end #----------------------------------------------------------------