Sha256: a23d662b59ef990873ca14bdfdc1b03c61ee6498cf4aa4961ee845600ede2b36
Contents?: true
Size: 609 Bytes
Versions: 1
Compression:
Stored size: 609 Bytes
Contents
# frozen_string_literal: true require_relative "futex/version" module Tlopo class Futex def initialize(path) @path = path @fh = nil end def locked? fh = File.open(@path, File::RDWR | File::CREAT, 0o644) r = fh.flock(File::LOCK_EX | File::LOCK_NB) fh.close r != 0 end def lock fh = File.open(@path, File::RDWR | File::CREAT, 0o644) fh.flock File::LOCK_EX @fh = fh end def release @fh.flock File::LOCK_UN @fh.close end def synchronize lock yield ensure release end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tlopo-futex-0.1.0 | lib/tlopo/futex.rb |