Module: Datadog::Profiling::Ext::DirClassMonkeyPatches

Defined in:
lib/datadog/profiling/ext/dir_monkey_patches.rb,
lib/datadog/profiling/ext/dir_monkey_patches.rb

Overview

Monkey patches for Dir.singleton_class (Ruby 3 version). See DirMonkeyPatches above for more details.

Instance Method Summary collapse

Instance Method Details

#[](*args, **kwargs, &block) ⇒ Object



33
34
35
36
37
38
# File 'lib/datadog/profiling/ext/dir_monkey_patches.rb', line 33

def [](*args, &block)
  Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
  super
ensure
  Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
end

#children(*args, **kwargs, &block) ⇒ Object



40
41
42
43
44
45
# File 'lib/datadog/profiling/ext/dir_monkey_patches.rb', line 40

def children(*args, &block)
  Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
  super
ensure
  Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
end

#each_child(*args, **kwargs, &block) ⇒ Object

See note on methods that yield above.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/datadog/profiling/ext/dir_monkey_patches.rb', line 53

def each_child(*args, &block)
  if block
    begin
      # <-- Begin critical region
      Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
      super do |entry_name|
        Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
        # <-- We're safe now while running customer code
        yield entry_name
        # <-- We'll go back to the Dir internals, critical region again
        Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
      end
    ensure
      # <-- End critical region
      Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
    end
  else
    # This returns an enumerator. We don't want/need to intercede here, the enumerator will eventually call the
    # other branch once it gets going.
    super
  end
end

#empty?(*args, **kwargs, &block) ⇒ Boolean

Returns:

  • (Boolean)


76
77
78
79
80
81
# File 'lib/datadog/profiling/ext/dir_monkey_patches.rb', line 76

def empty?(*args, &block)
  Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
  super
ensure
  Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
end

#entries(*args, **kwargs, &block) ⇒ Object



83
84
85
86
87
88
# File 'lib/datadog/profiling/ext/dir_monkey_patches.rb', line 83

def entries(*args, &block)
  Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
  super
ensure
  Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
end

#foreach(*args, **kwargs, &block) ⇒ Object

See note on methods that yield above.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/datadog/profiling/ext/dir_monkey_patches.rb', line 91

def foreach(*args, &block)
  if block
    begin
      # <-- Begin critical region
      Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
      super do |entry_name|
        Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
        # <-- We're safe now while running customer code
        yield entry_name
        # <-- We'll go back to the Dir internals, critical region again
        Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
      end
    ensure
      # <-- End critical region
      Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
    end
  else
    # This returns an enumerator. We don't want/need to intercede here, the enumerator will eventually call the
    # other branch once it gets going.
    super
  end
end

#glob(*args, **kwargs, &block) ⇒ Object

See note on methods that yield above.



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/datadog/profiling/ext/dir_monkey_patches.rb', line 115

def glob(*args, &block)
  if block
    begin
      # <-- Begin critical region
      Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
      super do |entry_name|
        Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
        # <-- We're safe now while running customer code
        yield entry_name
        # <-- We'll go back to the Dir internals, critical region again
        Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
      end
    ensure
      # <-- End critical region
      Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
    end
  else
    begin
      Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
      super
    ensure
      Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
    end
  end
end

#home(*args, **kwargs, &block) ⇒ Object



141
142
143
144
145
146
# File 'lib/datadog/profiling/ext/dir_monkey_patches.rb', line 141

def home(*args, &block)
  Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_hold_signals
  super
ensure
  Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_resume_signals
end