Module: RaceGuard::SharedState::Watcher

Defined in:
lib/race_guard/shared_state/watcher.rb

Overview

Adapts TracePoint payloads and dispatches to ConflictTracker (Epic 6.2–6.3).

Class Method Summary collapse

Class Method Details

.handle_event(event, mutex_skip: nil) ⇒ Object

For tests and future instrumentation (:read events).



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/race_guard/shared_state/watcher.rb', line 27

def handle_event(event, mutex_skip: nil)
  ev = coerce_event(event)
  return unless ev

  cfg = RaceGuard.configuration
  return unless cfg.active? && cfg.enabled?(TracePoint::FEATURE)

  guarded = if mutex_skip
              MutexStack.mutex_protected?(skip_frames: mutex_skip)
            else
              MutexStack.mutex_protected?
            end
  tracker.process!(ev, mutex_protected: guarded)
end

.handle_tracepoint(trace) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/race_guard/shared_state/watcher.rb', line 16

def handle_tracepoint(trace)
  ev = event_from_tracepoint(trace)
  return unless ev

  cfg = RaceGuard.configuration
  return unless cfg.active? && cfg.enabled?(TracePoint::FEATURE)

  tracker.process!(ev, mutex_protected: MutexStack.mutex_protected?)
end

.reset!Object



12
13
14
# File 'lib/race_guard/shared_state/watcher.rb', line 12

def reset!
  tracker.reset!
end

.trackerObject



8
9
10
# File 'lib/race_guard/shared_state/watcher.rb', line 8

def tracker
  @tracker ||= ConflictTracker.new
end