reentrant_mutex 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reentrant_mutex.rb +6 -5
- data/reentrant_mutex.gemspec +1 -1
- data/spec/reentrant_mutex_spec.rb +25 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a33897ff9e7cea3a5cbcfa698bb12641ad024c50
|
4
|
+
data.tar.gz: ec2ce7e6d7f82c7c38b2cfb47ffd986218db4775
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb58a48b1aea6294cc9cfe7522207c062b5692031a1c0556a430b72393d00cc80b8f111a84e29c4280e744f6d4e262f2f2afad471ca2445e3f2a2143d0a8ba6e
|
7
|
+
data.tar.gz: 2576e05e015ff280ab5ad6e3dace4ef376a0720883e23cf410a6b81034ddffc2ed3a5f775ce89c639f573866295cc61151a5ed4b38b95c4fe357f4a1c90f216a
|
data/lib/reentrant_mutex.rb
CHANGED
data/reentrant_mutex.gemspec
CHANGED
@@ -20,6 +20,18 @@ describe ReentrantMutex do
|
|
20
20
|
it 'should yield the block' do
|
21
21
|
expect{|b| mutex.synchronize &b}.to yield_with_no_args
|
22
22
|
end
|
23
|
+
|
24
|
+
it 'should leave the mutex unlocked' do
|
25
|
+
mutex.synchronize {}
|
26
|
+
|
27
|
+
expect(mutex.locked?).to be_false
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should be locked in the block' do
|
31
|
+
mutex.synchronize do
|
32
|
+
expect(mutex.locked?).to be_true
|
33
|
+
end
|
34
|
+
end
|
23
35
|
end
|
24
36
|
|
25
37
|
describe '#lock' do
|
@@ -27,6 +39,12 @@ describe ReentrantMutex do
|
|
27
39
|
mutex.lock
|
28
40
|
expect{mutex.lock}.not_to raise_error
|
29
41
|
end
|
42
|
+
|
43
|
+
it 'should lock the mutex' do
|
44
|
+
mutex.lock
|
45
|
+
|
46
|
+
expect(mutex.locked?).to be_true
|
47
|
+
end
|
30
48
|
end
|
31
49
|
|
32
50
|
describe '#unlock' do
|
@@ -41,5 +59,12 @@ describe ReentrantMutex do
|
|
41
59
|
expect{mutex.unlock}.not_to raise_error
|
42
60
|
expect{mutex.unlock}.not_to raise_error
|
43
61
|
end
|
62
|
+
|
63
|
+
it 'should unlock the mutex' do
|
64
|
+
mutex.lock
|
65
|
+
mutex.unlock
|
66
|
+
|
67
|
+
expect(mutex.locked?).to be_false
|
68
|
+
end
|
44
69
|
end
|
45
70
|
end
|