Sha256: efa1f69c85242e80756ec648fb14c619dffa6296b43e4a8ae4ef9e34f6638046
Contents?: true
Size: 386 Bytes
Versions: 1
Compression:
Stored size: 386 Bytes
Contents
class FlockMutex def initialize(path) @file = File.open(path, 'a') end def lock @file.flock(File::LOCK_EX) self end def unlock @file.flock(File::LOCK_UN) self end def synchronize lock yield ensure unlock end def locked? File.open(@file.path, 'a') do |f| ! f.flock(File::LOCK_EX | File::LOCK_NB) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
flock_mutex-1.0 | lib/flock_mutex.rb |