module SimpleCov::ResultMerger::ResultsetStore
def resultset_path
def resultset_path File.join(SimpleCov.coverage_path, ".resultset.json") end
def synchronize(&)
any given time. Reentrant: the lock is acquired once per outer
Ensure only one process is reading or writing the resultset at
def synchronize(&) return yield if @locked @locked = true with_flock(&) ensure @locked = false end
def with_flock
def with_flock FileUtils.mkdir_p(SimpleCov.coverage_path) File.open(writelock_path, "w+") do |f| f.flock(File::LOCK_EX) yield end end
def write(resultset)
def write(resultset) FileUtils.mkdir_p(SimpleCov.coverage_path) temp_path = "#{resultset_path}.#{Process.pid}.tmp" File.open(temp_path, "w") { |f| f.puts JSON.pretty_generate(resultset) } File.rename(temp_path, resultset_path) end
def writelock_path
def writelock_path File.join(SimpleCov.coverage_path, ".resultset.json.lock") end