Module: RaceGuard::SharedState::TracePoint

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

Overview

TracePoint listener for class- and global-variable assignments (Epic 6.1).

CRuby 3.x public TracePoint does not expose :cvasgn / :gvasgn (ArgumentError on new). This module still performs setup: when those events exist in a future MRI, they are used; otherwise a one-time Kernel.warn explains the limitation and nothing is installed (no blanket :c_call trace, which would be prohibitively expensive).

Opt in with RaceGuard.configure { |c| c.enable(:shared_state_watcher) }.

Constant Summary collapse

FEATURE =
:shared_state_watcher
INSTALL_MUTEX =
Mutex.new

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.event_sinkObject

Returns the value of attribute event_sink.



19
20
21
# File 'lib/race_guard/shared_state/trace_point.rb', line 19

def event_sink
  @event_sink
end

Class Method Details

.install!Object



36
37
38
39
40
41
# File 'lib/race_guard/shared_state/trace_point.rb', line 36

def install!
  INSTALL_MUTEX.synchronize do
    cfg = RaceGuard.configuration
    install_unlocked! if cfg.active? && cfg.enabled?(FEATURE)
  end
end

.installed?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/race_guard/shared_state/trace_point.rb', line 32

def installed?
  INSTALL_MUTEX.synchronize { !@trace.nil? || !@thread_trace.nil? }
end

.sync_with_configuration!Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/race_guard/shared_state/trace_point.rb', line 21

def sync_with_configuration!
  INSTALL_MUTEX.synchronize do
    cfg = RaceGuard.configuration
    if cfg.active? && cfg.enabled?(FEATURE)
      install_unlocked!
    else
      uninstall_unlocked!
    end
  end
end

.uninstall!Object



43
44
45
# File 'lib/race_guard/shared_state/trace_point.rb', line 43

def uninstall!
  INSTALL_MUTEX.synchronize { uninstall_unlocked! }
end