latch 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/latch.gemspec +2 -2
- data/lib/latch.rb +1 -1
- data/spec/latch_spec.rb +10 -15
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/latch.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{latch}
|
8
|
-
s.version = "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-
|
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 = [
|
data/lib/latch.rb
CHANGED
data/spec/latch_spec.rb
CHANGED
@@ -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.
|
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-
|
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: -
|
96
|
+
hash: -2726469313749246302
|
97
97
|
segments:
|
98
98
|
- 0
|
99
99
|
version: "0"
|