tresse 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/lib/tresse.rb +18 -9
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75e4b902710be0f597feab968d7b8fbcfbfa221f
4
- data.tar.gz: c0fa95c1637ab3391138bc27424bd916dd1e74d9
3
+ metadata.gz: a79478c19e535535d6939c00b57f34348dc024d3
4
+ data.tar.gz: f614a4fbc5b34a37617e3bb09863d09c5a1a95c6
5
5
  SHA512:
6
- metadata.gz: 62bbacc7d76b0c80eb11401221c6e4a088c97ea40d077344b5fa05fee41e77dfb36b0a28600cc1eba1e7c2f38607b44e164358e4d9e66f1fa82d185ad516f6d0
7
- data.tar.gz: 4cc9b5c16c00f742e509853d26ae7a6547650c67ba01d4b9a11da57ad55156b57d761f631b0b5b23d7c079304553cb380093479622c31f5d4003d8c633b80d9d
6
+ metadata.gz: 59dc4a2a63a63dfe420ae6ffb65b0a7e5083f55da03f630d74e42cb4f3c174081bf430e668820d55af76a6843f0db7b954f24a45e57978b8a33cb5ae2f1d5b24
7
+ data.tar.gz: e35f1a82c2c2e5aa65c5b17e0ca76d2aef068b9c9177b6f9a79f9fa2622ba2100e9663117ec333e0f70687a8383ba6d990fd844176dcfad03d958fe81cf91d3f
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## tresse 1.1.3 released 2019-09-17
6
+
7
+ * Fix ready for reduction check (prevent it from hanging)
8
+
9
+
5
10
  ## tresse 1.1.2 released 2019-09-17
6
11
 
7
12
  * Let Tresse::Group#flatten accept non-arrays
data/lib/tresse.rb CHANGED
@@ -4,7 +4,7 @@ require 'thread'
4
4
 
5
5
  module Tresse
6
6
 
7
- VERSION = '1.1.2'
7
+ VERSION = '1.1.3'
8
8
 
9
9
  class << self
10
10
 
@@ -93,6 +93,7 @@ module Tresse
93
93
 
94
94
  attr_reader :group
95
95
  attr_reader :map_index
96
+ attr_reader :completed
96
97
  attr_accessor :value
97
98
 
98
99
  def initialize(group, block_or_group)
@@ -102,6 +103,7 @@ module Tresse
102
103
 
103
104
  @map_index = -1
104
105
  @value = nil
106
+ @completed = false
105
107
  end
106
108
 
107
109
  def process
@@ -121,12 +123,16 @@ module Tresse
121
123
 
122
124
  @value = r if type == :map
123
125
  end
126
+
127
+ def complete
128
+
129
+ @completed = true
130
+ end
124
131
  end
125
132
 
126
133
  class Group
127
134
 
128
135
  attr_accessor :name
129
- #attr_reader :batches
130
136
 
131
137
  def initialize(name=nil)
132
138
 
@@ -137,7 +143,7 @@ module Tresse
137
143
  @maps = [ nil ]
138
144
 
139
145
  @reduce = nil
140
- @reduce_batches = []
146
+ @reduce_mutex = Mutex.new
141
147
  @reduction_queue = Queue.new
142
148
  end
143
149
 
@@ -242,15 +248,18 @@ module Tresse
242
248
 
243
249
  def queue_for_reduction(batch)
244
250
 
245
- @reduce_batches << batch
251
+ @reduce_mutex.synchronize do
246
252
 
247
- return if @reduce_batches.size < @batches.size
248
- return unless @reduce
253
+ batch.complete
249
254
 
250
- es = @batches.collect(&:value)
251
- target, block = @reduce
255
+ return unless @reduce
256
+ return if @batches.find { |b| ! b.completed }
252
257
 
253
- @reduction_queue << es.inject(target, &block)
258
+ es = @batches.collect(&:value)
259
+ target, block = @reduce
260
+
261
+ @reduction_queue << es.inject(target, &block)
262
+ end
254
263
  end
255
264
  end
256
265
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tresse
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux