yegor256 / futex Goto Github PK
View Code? Open in Web Editor NEWFile-based Ruby Mutex
Home Page: https://rubygems.org/gems/futex
License: MIT License
File-based Ruby Mutex
Home Page: https://rubygems.org/gems/futex
License: MIT License
The value of start
is incorrect.
Let's add a test for that situation
Let's inform the thread about our waiting status
Let's make it possible
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
Gemfile
ruby ~>2.3
Let's fix
Let's show them in logs/badges
Let's remove .lock
files after execution of open
. At the moment they stay together with original files and are simply a garbage.
This is what I tried: https://stackoverflow.com/questions/53011200/how-to-check-if-the-file-is-still-locked-by-current-thread
The problem will be solved when test_cleans_up_the_mess
test is not skipped anymore.
Let's put it in
Let's make it possible
Let's throw a custom exception type in case we fail to lock
Let's add this info
NoMethodError: undefined method `-' for nil:NilClass
/Users/yegor/.rvm/gems/ruby-2.6.0/gems/futex-0.8.4/lib/futex.rb:180:in `block in open_synchronized'
/Users/yegor/.rvm/gems/ruby-2.6.0/gems/futex-0.8.4/lib/futex.rb:192:in `block in synchronized'
/Users/yegor/.rvm/gems/ruby-2.6.0/gems/futex-0.8.4/lib/futex.rb:190:in `open'
/Users/yegor/.rvm/gems/ruby-2.6.0/gems/futex-0.8.4/lib/futex.rb:190:in `synchronized'
/Users/yegor/.rvm/gems/ruby-2.6.0/gems/futex-0.8.4/lib/futex.rb:177:in `ensure in open_synchronized'
/Users/yegor/.rvm/gems/ruby-2.6.0/gems/futex-0.8.4/lib/futex.rb:177:in `open_synchronized'
/Users/yegor/.rvm/gems/ruby-2.6.0/gems/futex-0.8.4/lib/futex.rb:103:in `open'
Let's print relative file names, instead of absolute ones (make sure this feature is configurable):
require 'futex'
Futex.new('/tmp/my-file.txt', absolute_file_names: true).open |f|
IO.read(f)
end
By default this should be set to false
.
This is what I see now in logs:
#83543/ can't get exclusive access to the file /private/var/folders/vl/633jwjvn2jvbj9zfg1sgglhw0000gp/T/d20181120-83431-1gu0e5m/cb19b5d996fe7f19.z because of the lock at /private/var/folders/vl/633jwjvn2jvbj9zfg1sgglhw0000gp/T/d20181120-83431-1gu0e5m/cb19b5d996fe7f19.z.lock, after 16000ms of waiting: #83543/
I want to see this:
#83543/ can't get exclusive access to the file cb19b5d996fe7f19.z because of the lock at cb19b5d996fe7f19.z.lock, after 16000ms of waiting: #83543/
When it's nil, let's log it right anyway
NoMethodError - undefined method `close' for nil:NilClass:
/Users/yegor/.rvm/gems/ruby-2.5.1/gems/futex-0.8.3/lib/futex.rb:178:in `block in open_synchronized'
/Users/yegor/.rvm/gems/ruby-2.5.1/gems/futex-0.8.3/lib/futex.rb:192:in `block in synchronized'
/Users/yegor/.rvm/gems/ruby-2.5.1/gems/futex-0.8.3/lib/futex.rb:190:in `open'
/Users/yegor/.rvm/gems/ruby-2.5.1/gems/futex-0.8.3/lib/futex.rb:190:in `synchronized'
/Users/yegor/.rvm/gems/ruby-2.5.1/gems/futex-0.8.3/lib/futex.rb:177:in `ensure in open_synchronized'
/Users/yegor/.rvm/gems/ruby-2.5.1/gems/futex-0.8.3/lib/futex.rb:177:in `open_synchronized'
/Users/yegor/.rvm/gems/ruby-2.5.1/gems/futex-0.8.3/lib/futex.rb:103:in `open'
https://ci.appveyor.com/project/yegor256/futex/build/job/1wmn2jfi5wce1f96
Errno::EACCES: Permission denied @ fptr_finalize - C:/Users/appveyor/AppData/Local/Temp/1/d20181109-2536-mxashs/a/b/c/file.txt.lock
C:/projects/futex/lib/futex.rb:89:in `write'
C:/projects/futex/lib/futex.rb:89:in `block in open'
C:/projects/futex/lib/futex.rb:70:in `open'
C:/projects/futex/lib/futex.rb:70:in `open'
C:/projects/futex/test/test_futex.rb:52:in `block (2 levels) in test_syncs_access_to_file_in_slow_motion'
C:/projects/futex/vendor/bundle/ruby/2.3.0/gems/threads-0.3.0/lib/threads.rb:57:in `block (3 levels) in assert'
C:/projects/futex/vendor/bundle/ruby/2.3.0/gems/threads-0.3.0/lib/threads.rb:53:in `loop'
C:/projects/futex/vendor/bundle/ruby/2.3.0/gems/threads-0.3.0/lib/threads.rb:53:in `block (2 levels) in assert'
C:/projects/futex/vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.1.3/lib/concurrent/executor/ruby_thread_pool_executor.rb:348:in `run_task'
C:/projects/futex/vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.1.3/lib/concurrent/executor/ruby_thread_pool_executor.rb:337:in `block (3 levels) in create_worker'
C:/projects/futex/vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.1.3/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `loop'
C:/projects/futex/vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.1.3/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `block (2 levels) in create_worker'
C:/projects/futex/vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.1.3/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `catch'
C:/projects/futex/vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.1.3/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `block in create_worker'
Let's make it local, one per each lock
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.