futex 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5106ee1a1a428a57559341311f6f66cdcff6b0d15453b1925e0ad570bf4f5a6
4
- data.tar.gz: 88ff9063aff0aa87a71426808fd82b3324e5a819d3a3669f83e2900fb673dec0
3
+ metadata.gz: 729dc25954a8a169668ca2d458d24156c8b4d2555a5945714ededf99fadad3fe
4
+ data.tar.gz: 82fb28cad4a9ad74152ebb4e5160971a66d14b0897c952297a69868ee2b0a067
5
5
  SHA512:
6
- metadata.gz: 68f618ed73bee632c43c350812cbf88aa1107871d15561e5cb76f9127fa29e5c223b523d31e34289dc87031b9b13bf5422ca6d6e031a675e934594551cfb822f
7
- data.tar.gz: 7d666e9b80b81670bab473327c30dbd91a178ebf1690c0aae6c469d76099faf38a4fef0028b0596b94faa44f392a5eee384c2352b5e5c2184aded3124f650f57
6
+ metadata.gz: 43337117eab085f589235a636f33fc801a27b21378011ff199a805fd213f9df7a5c6c2e90467290547184f0777ecc58a3c2a77a06c5d562f7d4eae1f62dacf4d
7
+ data.tar.gz: 024ddc3edc4bcf35beb17f468867d8f9d4feccf1214e8ba4f05f3c9718770653edf70fc8060f47c0ddb9637241e3a837915e6ea926d6e5b669f8d3082f6adec9
data/.rubocop.yml CHANGED
@@ -7,7 +7,9 @@ Layout/EmptyLineAfterGuardClause:
7
7
  Layout/MultilineMethodCallIndentation:
8
8
  Enabled: false
9
9
  Metrics/AbcSize:
10
- Max: 50
10
+ Max: 60
11
+ Metrics/BlockLength:
12
+ Max: 30
11
13
  Metrics/MethodLength:
12
14
  Max: 40
13
15
  Metrics/ClassLength:
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.6.0'
34
+ s.version = '0.6.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
@@ -76,6 +76,8 @@ class Futex
76
76
  cycle = 0
77
77
  loop do
78
78
  if f.flock((exclusive ? File::LOCK_EX : File::LOCK_SH) | File::LOCK_NB)
79
+ Thread.current.thread_variable_set(:futex_cycle, nil)
80
+ Thread.current.thread_variable_set(:futex_time, nil)
79
81
  break
80
82
  end
81
83
  sleep(@sleep)
@@ -98,6 +100,8 @@ access to #{@path}, #{age(start)} already: #{IO.read(@lock)}")
98
100
  acq = Time.now
99
101
  res = yield(@path)
100
102
  debug("Unlocked by #{b} in #{age(acq)}, #{prefix}exclusive: #{@path}")
103
+ Thread.current.thread_variable_set(:futex_lock, nil)
104
+ Thread.current.thread_variable_set(:futex_badge, nil)
101
105
  res
102
106
  end
103
107
  end
data/test/test_futex.rb CHANGED
@@ -141,6 +141,15 @@ class FutexTest < Minitest::Test
141
141
  end
142
142
  end
143
143
 
144
+ def test_removes_thread_vars
145
+ Dir.mktmpdir do |dir|
146
+ Futex.new(File.join(dir, 'hey.txt')).open do |f|
147
+ # nothing
148
+ end
149
+ assert(Thread.current.thread_variable_get(:futex_lock).nil?)
150
+ end
151
+ end
152
+
144
153
  def test_saves_calling_file_name_in_lock
145
154
  Dir.mktmpdir do |dir|
146
155
  Futex.new(File.join(dir, 'hey.txt')).open do |f|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: futex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko