summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-05-20 18:42:37 -0600
committermo khan <mo.khan@gmail.com>2020-05-20 18:42:37 -0600
commit5d687dfd06dd2b4adbc3848dfec40c8360352093 (patch)
tree92b0f7c3d346e6f66f924831061f8598a55b605e /lib
parent1f74ee1f3d27c173e1630609df1464706d715c3b (diff)
Delete ThreadPool
Diffstat (limited to 'lib')
-rw-r--r--lib/spandx/core/thread_pool.rb49
1 files changed, 0 insertions, 49 deletions
diff --git a/lib/spandx/core/thread_pool.rb b/lib/spandx/core/thread_pool.rb
deleted file mode 100644
index 79426a4..0000000
--- a/lib/spandx/core/thread_pool.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-# frozen_string_literal: true
-
-module Spandx
- module Core
- class ThreadPool
- def initialize(size: Etc.nprocessors)
- @size = size
- @queue = Queue.new
- @pool = size.times.map { start_worker_thread }
- end
-
- def schedule(*args, &block)
- @queue.enq([block, args])
- end
-
- def done?
- @queue.empty?
- end
-
- def shutdown
- @size.times do
- schedule { throw :exit }
- end
-
- @pool.map(&:join)
- end
-
- def self.open
- pool = new
- yield pool
- ensure
- pool.shutdown
- end
-
- private
-
- def start_worker_thread
- Thread.new do
- catch(:exit) do
- loop do
- job, args = @queue.deq
- job.call(*args)
- end
- end
- end
- end
- end
- end
-end