futex 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/futex.gemspec +1 -1
- data/lib/futex.rb +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7d43b57ed9b9c1976f33c1da3d39e9646bbb5e890594c339ca7178da830db81
|
4
|
+
data.tar.gz: 7584b99738962f3526367c4310a5a626e8bcec599e5064350825f7a784ab0fac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8af3cb3b44c1e665d0a7744b5321b2084844d1b8c31b73cc37ea1abe47cc6e9c30ace004fd6abac823998a3584385ac18de237bebd53fc6702df186e2646b0bf
|
7
|
+
data.tar.gz: c99a473b9ecf837cfc95d852ce2e5886b492ce19cba9929cc3dbaef70f80d8bccbb182f9ae08006f6e5ae35611af2819ef0ae4532e00670f6c91c75016a52c90
|
data/futex.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.rubygems_version = '2.3.3'
|
32
32
|
s.required_ruby_version = '>=2.3'
|
33
33
|
s.name = 'futex'
|
34
|
-
s.version = '0.3.
|
34
|
+
s.version = '0.3.1'
|
35
35
|
s.license = 'MIT'
|
36
36
|
s.summary = 'File-based mutex'
|
37
37
|
s.description = 'Ruby Gem for file-based locking'
|
data/lib/futex.rb
CHANGED
@@ -60,17 +60,17 @@ class Futex
|
|
60
60
|
cycle += 1
|
61
61
|
if Time.now - start > @timeout
|
62
62
|
raise "##{Process.pid}/#{Thread.current.name} can't get \
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
exclusive access to the file #{@path} \
|
64
|
+
because of the lock at #{@lock}, after #{age(start)} \
|
65
|
+
of waiting: #{IO.read(@lock)}"
|
66
66
|
end
|
67
67
|
if (cycle % step).zero? && Time.now - start > @timeout / 2
|
68
68
|
debug("##{Process.pid}/#{Thread.current.name} still waiting for \
|
69
|
-
|
69
|
+
exclusive access to #{@path}, #{age(start)} already: #{IO.read(@lock)}")
|
70
70
|
end
|
71
71
|
end
|
72
72
|
debug("Locked by \"#{Thread.current.name}\" in #{age(start)}: #{@path} \
|
73
|
-
|
73
|
+
(attempt no.#{cycle})")
|
74
74
|
File.write(@lock, "##{Process.pid}/#{Thread.current.name}")
|
75
75
|
acq = Time.now
|
76
76
|
res = yield(@path)
|