thread 0.1.2 → 0.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/lib/thread/channel.rb +12 -8
  3. data/thread.gemspec +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f8b2b8b2de2d12fa2255966aea69b62e0be09e2
4
- data.tar.gz: 5b8c58cdca06730258e4481ea6d5ff8cb2c62d58
3
+ metadata.gz: 915dd79486e7e628d223363cc58d22072872ba2e
4
+ data.tar.gz: 2a4c8d5cf1c04be29d42a29378eac723aed48907
5
5
  SHA512:
6
- metadata.gz: 362ca6bf0a6b5e7fe907cbb1d060facba2bbe7ebbb8e93604b220cba505d9ffbe3e8216a058d051133c5314332e9f00e2933452b302ea264e65b69f6cfa69a8e
7
- data.tar.gz: 99296e2a1bff5431616265fc921cf2d886b17e4ee0ba4dca4dffebd1b81877921818133fe4e50a82559352c3555c065d6098e4024bda7f3a55c73ddf95650a76
6
+ metadata.gz: 4b4049d70035accffa58a8640564716f169f48f65a18e5eb7e4eb7b3c353f71be3610339e6179edaa56ac76abae3e6d94ac214df59fbcbaadb22cf2d8152c215
7
+ data.tar.gz: 1fe65f80b58a88d04c3b9de5cecd1f2d5bcf0a569b78f3dc5d6c8f5ee2c533b4ab70a8d367c089029ec8fb68d8a6a337fb953f36d1cc1f4c44b772dad7c1f6e6
@@ -49,10 +49,9 @@ class Thread::Channel
49
49
  # If a block is passed, it's used as guard to match to a message.
50
50
  def receive (&block)
51
51
  message = nil
52
+ found = false
52
53
 
53
54
  if block
54
- found = false
55
-
56
55
  until found
57
56
  @mutex.synchronize {
58
57
  if index = @messages.find_index(&block)
@@ -64,13 +63,18 @@ class Thread::Channel
64
63
  }
65
64
  end
66
65
  else
67
- @mutex.synchronize {
68
- if @messages.empty?
69
- cond.wait @mutex
70
- end
66
+ until found
67
+ @mutex.synchronize {
68
+ if @messages.empty?
69
+ cond.wait @mutex
70
+ end
71
71
 
72
- message = @messages.shift
73
- }
72
+ unless @messages.empty?
73
+ message = @messages.shift
74
+ found = true
75
+ end
76
+ }
77
+ end
74
78
  end
75
79
 
76
80
  message
data/thread.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new {|s|
2
2
  s.name = 'thread'
3
- s.version = '0.1.2'
3
+ s.version = '0.1.3'
4
4
  s.author = 'meh.'
5
5
  s.email = 'meh@schizofreni.co'
6
6
  s.homepage = 'http://github.com/meh/ruby-thread'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thread
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - meh.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-14 00:00:00.000000000 Z
11
+ date: 2013-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec