futex 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/futex.gemspec +1 -1
  3. data/lib/futex.rb +6 -6
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 621fe1e76d09dd787dc6e5a76b7137d44f981ac303d5c0e825a0af6d885695ca
4
- data.tar.gz: 0ab8b3899131e5e5514e2ede85cc7f18825a74915fa59b26e50e4712c1e0f0c8
3
+ metadata.gz: 304cc67b805690f790a453273a62956b240d871b35aceb85fd3914b0a844f419
4
+ data.tar.gz: 777127ff698b47ac49d6477ad753cbad9479c62cf57951eeb05dc4fa83da3ad9
5
5
  SHA512:
6
- metadata.gz: 8b2a86b5382799a2b3f7591d0408bae3a1fc3f9b2f01b99b24e18b0598de50d9a04bf2904619ad135322346de41ee72e3b96a1de71fd9b74046495f1203e2ed6
7
- data.tar.gz: a9fa21e4a920d835454fa47f458933e1810344677e870a8df7c45f1919db4dfc3e6324b5a6876e6ffa9bbbbce4bf0506e755afbab10e25e6fb7d426195ab6c93
6
+ metadata.gz: 96cc04db67df9cc3560639369e0b0715cec5c61483e107235c27ebd5efd33063812675d0d96323fc9928b6d7854d5bc810b5bf05a6e7b0bb68b0857fb209123b
7
+ data.tar.gz: 7ac2732a0196fceb094b9381dc7dad8e18dcbae6dc8ba55878c1fa4e2a465c0423c999bcb75f5b4df5295425b9c519698b1a719513d8c46471b01d376418de94
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.8.3'
34
+ s.version = '0.8.4'
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
@@ -124,7 +124,7 @@ access to #{@path}, #{age(start)} already: #{IO.read(@lock)} \
124
124
  end
125
125
  debug("Locked by #{b} in #{age(start)}, #{prefix}exclusive: \
126
126
  #{@path} (attempt no.#{cycle})")
127
- File.write(@lock, b)
127
+ IO.write(@lock, b)
128
128
  acq = Time.now
129
129
  res = block_given? ? yield(@path) : nil
130
130
  debug("Unlocked by #{b} in #{age(acq)}, #{prefix}exclusive: #{@path}")
@@ -168,21 +168,21 @@ access to #{@path}, #{age(start)} already: #{IO.read(@lock)} \
168
168
  file = nil
169
169
  synchronized do |counts|
170
170
  file = File.open(path, File::CREAT | File::RDWR)
171
- refs = deserialize(File.read(counts.path))
171
+ refs = deserialize(IO.read(counts.path))
172
172
  refs[path] = (refs[path] || 0) + 1
173
- File.write(counts.path, serialize(refs))
173
+ IO.write(counts.path, serialize(refs))
174
174
  end
175
175
  yield file
176
176
  ensure
177
177
  synchronized do |counts|
178
- file.close
179
- refs = deserialize(File.read(counts.path))
178
+ file&.close
179
+ refs = deserialize(IO.read(counts.path))
180
180
  refs[path] -= 1
181
181
  if refs[path].zero?
182
182
  FileUtils.rm(path, force: true)
183
183
  refs.delete(path)
184
184
  end
185
- File.write(counts.path, serialize(refs))
185
+ IO.write(counts.path, serialize(refs))
186
186
  end
187
187
  end
188
188
 
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.8.3
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko