thimble 0.0.3 → 0.0.4
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 +4 -4
- data/lib/Manager.rb +5 -1
- data/lib/Thimble.rb +5 -3
- data/lib/ThimbleQueue.rb +8 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cebbbfa65f3152884f14c9fc1bb11cae470091d6
|
4
|
+
data.tar.gz: 24fd1d8b85f33ffd2c09bc428a31c92d81d61a78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e89f4aaa7534ab60c6ee2b88224e92407758eeb7a6575d6dc2ec567a411d443ec6da9a0f4321b3d1440fe3be77249ad3803f4ebf22988176be6785c6254cd6ba
|
7
|
+
data.tar.gz: c9bb385dc43f7e3e12bf9e5c9a8d9b08600f67cffafdc343f66ff0fca8eba067a7471997e2959c34254a6fc4b71184204f11fbb304f3a4c974a14c66f0202df3
|
data/lib/Manager.rb
CHANGED
data/lib/Thimble.rb
CHANGED
@@ -19,7 +19,7 @@ module Thimble
|
|
19
19
|
close()
|
20
20
|
end
|
21
21
|
|
22
|
-
#
|
22
|
+
# requires a block
|
23
23
|
def par_map
|
24
24
|
@running = true
|
25
25
|
while @running
|
@@ -41,7 +41,7 @@ module Thimble
|
|
41
41
|
def get_batch
|
42
42
|
batch = []
|
43
43
|
while batch.size < @manager.batch_size
|
44
|
-
item = next
|
44
|
+
item = self.next
|
45
45
|
if item.nil?
|
46
46
|
return nil if batch.size == 0
|
47
47
|
return QueueItem.new(batch, "Batch")
|
@@ -66,7 +66,9 @@ module Thimble
|
|
66
66
|
if @manager.worker_type == :fork
|
67
67
|
if tuple.reader.ready?
|
68
68
|
piped_result = tuple.reader.read
|
69
|
-
|
69
|
+
loadedResult = Marshal.load(piped_result)
|
70
|
+
loadedResult.each { |r| raise r if r.class <= Exception }
|
71
|
+
push_result(loadedResult)
|
70
72
|
Process.kill("HUP", tuple.pid)
|
71
73
|
@manager.rem_worker(tuple)
|
72
74
|
end
|
data/lib/ThimbleQueue.rb
CHANGED
@@ -3,6 +3,7 @@ require_relative 'QueueItem'
|
|
3
3
|
|
4
4
|
module Thimble
|
5
5
|
class ThimbleQueue
|
6
|
+
include Enumerable
|
6
7
|
attr_reader :size
|
7
8
|
def initialize(size, name)
|
8
9
|
raise ArgumentError.new("make sure there is a size for the queue greater than 1! size received #{size}") unless size >= 1
|
@@ -16,6 +17,12 @@ module Thimble
|
|
16
17
|
@empty = ConditionVariable.new
|
17
18
|
@full = ConditionVariable.new
|
18
19
|
end
|
20
|
+
|
21
|
+
def each
|
22
|
+
while item = self.next
|
23
|
+
yield item.item
|
24
|
+
end
|
25
|
+
end
|
19
26
|
|
20
27
|
def next
|
21
28
|
@mutex.synchronize do
|
@@ -68,7 +75,7 @@ module Thimble
|
|
68
75
|
|
69
76
|
def to_a
|
70
77
|
a = []
|
71
|
-
while item = next
|
78
|
+
while item = self.next
|
72
79
|
a << item.item
|
73
80
|
end
|
74
81
|
a
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thimble
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kovanda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Pass a block and get some results
|
14
14
|
email: andrew.kovanda@gmail.com
|