futex 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/futex.gemspec +1 -1
- data/lib/futex.rb +1 -1
- data/test/test_futex.rb +2 -2
- 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: bc966cb2da1f00c01883f0c460f481110c8fa74ee6aa6b10ce4a1355d40d211b
|
4
|
+
data.tar.gz: c9e9794071fe3e2984bd6a411dd57fd20b9a4e67a18cd4843b60a609bd212aff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86431c6b633f2d3485ca2321110853c198904682b5498a2cb439b702be54e012ab0b3204887e893a92c116111d04d36fa841c8a72edac6f41f8939bfe1f2683a
|
7
|
+
data.tar.gz: e77aa4ee5b397613df270f476f69e2297b4e26f18296391a9e4b9421201a368d9e992afa06ddaa7f5580e91944b141f64b0d31f9614e379f261da7e220edf76e
|
data/README.md
CHANGED
@@ -34,7 +34,7 @@ constructor of the `Futex` class, including:
|
|
34
34
|
* `log`: an object that implements `debug()` method, which will
|
35
35
|
receive supplementary messages from the locking mechanism;
|
36
36
|
|
37
|
-
* `logging`: set it to `
|
37
|
+
* `logging`: set it to `true` if you want to see logs;
|
38
38
|
|
39
39
|
* `timeout`: the number of seconds to wait for the lock availability
|
40
40
|
(an exception is raised when the wait is expired);
|
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.
|
34
|
+
s.version = '0.3.0'
|
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
@@ -31,7 +31,7 @@ require 'time'
|
|
31
31
|
# License:: MIT
|
32
32
|
class Futex
|
33
33
|
def initialize(path, log: STDOUT, timeout: 16, sleep: 0.005,
|
34
|
-
lock: path + '.lock', logging:
|
34
|
+
lock: path + '.lock', logging: false)
|
35
35
|
raise "File path can't be nil" if path.nil?
|
36
36
|
@path = path
|
37
37
|
raise "Log can't be nil" if log.nil?
|
data/test/test_futex.rb
CHANGED
@@ -36,7 +36,7 @@ class FutexTest < Minitest::Test
|
|
36
36
|
Dir.mktmpdir do |dir|
|
37
37
|
path = File.join(dir, 'a/b/c/file.txt')
|
38
38
|
Threads.new(2).assert do |_, r|
|
39
|
-
Futex.new(path, logging:
|
39
|
+
Futex.new(path, logging: true).open do |f|
|
40
40
|
text = "op no.#{r}"
|
41
41
|
IO.write(f, text)
|
42
42
|
assert_equal(text, IO.read(f))
|
@@ -49,7 +49,7 @@ class FutexTest < Minitest::Test
|
|
49
49
|
Dir.mktmpdir do |dir|
|
50
50
|
path = File.join(dir, 'a/b/c/file.txt')
|
51
51
|
Threads.new(20).assert(200) do |_, r|
|
52
|
-
Futex.new(path
|
52
|
+
Futex.new(path).open do |f|
|
53
53
|
text = "op no.#{r}"
|
54
54
|
IO.write(f, text)
|
55
55
|
sleep 0.01
|