specwrk 0.10.1 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9dfd4ef167bef2dc36de450f5855ff2ff376255ddd1e471426e08cb20d91a615
4
- data.tar.gz: 0107c130003c627c5f3cc50949d9dc6cd3563e4f810b799527e6aa2234a19822
3
+ metadata.gz: 4570e3aaeb01c00647b8671803076848bf28dee5068ec0cde66c88effea85bbe
4
+ data.tar.gz: 1d6709fc4b518ca5dcbad15e59820ba855adebb5dc6830ec26cc7f92d59f597d
5
5
  SHA512:
6
- metadata.gz: 1ffb03334f25bb2ca19a45e3004feb80ab3565e12c2e8aad43565000e741b37b2aa296683c1cf5215571cd25a79f5f53934cdfc427fea89a44e92d49d8c0a076
7
- data.tar.gz: 4eb0f0e1a9469b1d0f23952d06b24b873d98e25ec3777bedf94a0b2be904038b225f39e9395556350c8c1cd057086f7af8866fbb38bf79ea5937b531be690993
6
+ metadata.gz: 3868e891fc3c14a8ce281b747d8e5b0c271e55f946f1fe1d23aa4d88d940ee40ea966fbf32bce5711ca1597c7870a8a4b1aa1bac610f117a9695888015eee6db
7
+ data.tar.gz: 385faa8d85c751eca15e1203ab626ec8d9abe3584e79265550dc52b18c81327f6a837535827dd63d56bc5fb0671fe11c8bd91698a96dc0d9a82d36a23edc7430
@@ -10,20 +10,24 @@ module Specwrk
10
10
  class FileAdapter
11
11
  EXT = ".wrk.json"
12
12
 
13
- THREAD_POOL = Class.new do
14
- @work_queue = Queue.new
13
+ @work_queue = Queue.new
14
+ @threads = []
15
15
 
16
- @threads = Array.new(ENV.fetch("SPECWRK_SRV_FILE_ADAPTER_THREAD_COUNT", "4").to_i) do
17
- Thread.new do
18
- loop do
19
- @work_queue.pop.call
20
- end
21
- end
16
+ class << self
17
+ def schedule_work(&blk)
18
+ start_threads!
19
+ @work_queue.push blk
22
20
  end
23
21
 
24
- class << self
25
- def schedule(&blk)
26
- @work_queue.push blk
22
+ def start_threads!
23
+ return if @threads.length.positive?
24
+
25
+ Array.new(ENV.fetch("SPECWRK_THREAD_COUNT", "4").to_i) do
26
+ @threads << Thread.new do
27
+ loop do
28
+ @work_queue.pop.call
29
+ end
30
+ end
27
31
  end
28
32
  end
29
33
  end
@@ -80,7 +84,7 @@ module Specwrk
80
84
  result_queue = Queue.new
81
85
 
82
86
  read_keys.each do |key|
83
- THREAD_POOL.schedule do
87
+ self.class.schedule_work do
84
88
  result_queue.push([key.to_s, read(key)])
85
89
  end
86
90
  end
@@ -107,7 +111,7 @@ module Specwrk
107
111
  hash_with_filenames.each do |key, (filename, value)|
108
112
  content = JSON.generate(value)
109
113
 
110
- THREAD_POOL.schedule do
114
+ self.class.schedule_work do
111
115
  result_queue << write(filename, content)
112
116
  end
113
117
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Specwrk
4
- VERSION = "0.10.1"
4
+ VERSION = "0.10.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specwrk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Westendorf