Module: Corkscrews::Primitives::MutexStamp

Defined in:
lib/corkscrews/primitives.rb

Overview

Paper basis: Ousterhout et al. NSDI'15 Section 2.3.1 instruments time spent blocked from the compute thread's perspective; these prepends adapt that blocked-time accounting to Ruby waits. Paper URL: https://www.usenix.org/system/files/conference/nsdi15/nsdi15-paper-ousterhout.pdf

Instance Method Summary collapse

Instance Method Details

#lockObject



18
19
20
21
22
23
24
# File 'lib/corkscrews/primitives.rb', line 18

def lock
  started_ns = Corkscrews::TimeSource.monotonic_ns
  result = super
  Corkscrews.record_wait(:lock_wait, Corkscrews::TimeSource.monotonic_ns - started_ns)
  Corkscrews::Native.stamp_inherit(self)
  result
end

#synchronize(&block) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/corkscrews/primitives.rb', line 26

def synchronize(&block)
  lock
  begin
    block.call
  ensure
    unlock
  end
end

#unlockObject



13
14
15
16
# File 'lib/corkscrews/primitives.rb', line 13

def unlock
  Corkscrews::Native.stamp_write(self)
  super
end