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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ThimbleQueue.rb +15 -3
  3. metadata +6 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 876ed0c4e7c36a4db72917f3e6682391d9b4ab93
4
- data.tar.gz: bc7094a52c39b3d7195eb00e34a597446d9167df
3
+ metadata.gz: 3b25fd7c92e8dafb66ba3bd700e82e25cb3cbf4f
4
+ data.tar.gz: 2f6d476abbfdb1d1cdad7363c865592995252d1f
5
5
  SHA512:
6
- metadata.gz: c3018294460c6e4178d9e41c7ec6a40a42ee147ef56f2cb4a5cd4a0803d28c4d08715830b717087b0ac31b3fda3bafae00ba5eef55d69e0fb4789be9f8478e58
7
- data.tar.gz: 79ca0d81350830cff5825130f881ceedfc632e0bcd35f67cb9bbb8054dd0a0d87036878ffc66912437584d5dddf2805df6d437c484f6b3e4bdb49b3c8f11de00
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.5
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-21 00:00:00.000000000 Z
11
+ date: 2016-03-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Pass a block and get some results
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: []