latch 0.3.0 → 0.4.0

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 (5) hide show
  1. data/VERSION +1 -1
  2. data/latch.gemspec +2 -2
  3. data/lib/latch.rb +1 -1
  4. data/spec/latch_spec.rb +10 -15
  5. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{latch}
8
- s.version = "0.3.0"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kyle Maxwell"]
12
- s.date = %q{2011-05-01}
12
+ s.date = %q{2011-05-02}
13
13
  s.description = %q{This is a really simple countdown latch for Ruby.}
14
14
  s.email = %q{kyle@kylemaxwell.com}
15
15
  s.extra_rdoc_files = [
@@ -39,7 +39,7 @@ class Latch
39
39
  end
40
40
 
41
41
  def await(timeout = nil)
42
- @cv.wait(@mutex, timeout)
42
+ @cv.wait(@mutex, timeout) if @count > 0
43
43
  raise @exception if @exception
44
44
  raise Latch::Timeout if @count > 0
45
45
  end
@@ -17,6 +17,16 @@ describe "Latch" do
17
17
  (Time.now - start).should > EPSILON
18
18
  end
19
19
 
20
+ it "should not race creation" do
21
+ start = Time.now
22
+ l = Latch.new(ITEMS)
23
+ Thread.new do
24
+ l.decr
25
+ end
26
+ l.await
27
+ (Time.now - start).should < EPSILON
28
+ end
29
+
20
30
  it "should wait for the block" do
21
31
  start = Time.now
22
32
  Latch::Mixin::latch do |l|
@@ -40,21 +50,6 @@ describe "Latch" do
40
50
  }.should raise_error(Latch::Timeout)
41
51
  end
42
52
 
43
- it "should raise the exception in the outer thread" do
44
- start = Time.now
45
- proc {
46
- Latch::Mixin::latch(ITEMS, EPSILON) do |l|
47
- Thread.new do
48
- begin
49
- l.fail(CustomError)
50
- rescue => e
51
- puts e.message
52
- end
53
- end
54
- end
55
- }.should raise_error(CustomError)
56
- end
57
-
58
53
  it "should have sugar for catching exceptions" do
59
54
  start = Time.now
60
55
  proc {
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: latch
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.0
5
+ version: 0.4.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kyle Maxwell
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-01 00:00:00 -07:00
13
+ date: 2011-05-02 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -93,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- hash: -4234111217352214708
96
+ hash: -2726469313749246302
97
97
  segments:
98
98
  - 0
99
99
  version: "0"