thimble 0.0.5 → 0.0.6
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/ThimbleQueue.rb +15 -3
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b25fd7c92e8dafb66ba3bd700e82e25cb3cbf4f
|
4
|
+
data.tar.gz: 2f6d476abbfdb1d1cdad7363c865592995252d1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa40124bea0b95345aa758fa667d264343b34296829854b954f7f6652cd177caaacac713c507a5e467eb846adc733a273fbb52d3f58e5aad99b3b1ee3cfa1240
|
7
|
+
data.tar.gz: 85144ec759b08b56f60b18fb0a790d9c927b9efbcb92665ca5d2c4f9e922bcc3bd88ca1e7a17ef1f163577b3cca11c75fc3219934934c997b976553759c040b6
|
data/lib/ThimbleQueue.rb
CHANGED
@@ -23,7 +23,19 @@ module Thimble
|
|
23
23
|
yield item.item
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
|
+
def length
|
28
|
+
size
|
29
|
+
end
|
30
|
+
|
31
|
+
def +(other)
|
32
|
+
raise ArgumentError.new("+ requires another Enumerable!") unless other.class < Enumerable
|
33
|
+
merged_thimble = ThimbleQueue.new(length + other.length, @name)
|
34
|
+
self.each {|item| merged_thimble.push(item)}
|
35
|
+
other.each {|item| merged_thimble.push(item)}
|
36
|
+
merged_thimble
|
37
|
+
end
|
38
|
+
|
27
39
|
def next
|
28
40
|
@mutex.synchronize do
|
29
41
|
while !@close_now
|
@@ -41,7 +53,7 @@ module Thimble
|
|
41
53
|
|
42
54
|
# This will push whatever it is handed to the queue
|
43
55
|
def push(x)
|
44
|
-
raise "Queue is closed!" if @closed
|
56
|
+
raise RuntimeError.new("Queue is closed!") if @closed
|
45
57
|
@mutex.synchronize do
|
46
58
|
while !offer(x)
|
47
59
|
@full.wait(@mutex)
|
@@ -53,7 +65,7 @@ module Thimble
|
|
53
65
|
# This will flatten any nested arrays out and feed them one at
|
54
66
|
# a time to the queue.
|
55
67
|
def push_flat(x)
|
56
|
-
raise "Queue is closed!" if @closed
|
68
|
+
raise RuntimeError.new("Queue is closed!") if @closed
|
57
69
|
if x.respond_to? :each
|
58
70
|
x.each {|item| push(item)}
|
59
71
|
else
|
metadata
CHANGED
@@ -1,16 +1,19 @@
|
|
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.6
|
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-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: Thimble is a ruby gem for parallelism and concurrency. It allows you
|
14
|
+
to decide if you want to use separate processes, or if you want to use threads in
|
15
|
+
ruby. It allows you to create stages with a thread safe queue, and break apart large
|
16
|
+
chunks of work.
|
14
17
|
email: andrew.kovanda@gmail.com
|
15
18
|
executables: []
|
16
19
|
extensions: []
|