summaryrefslogtreecommitdiff
path: root/trace_point.rb
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2021-12-09 03:50:17 +0900
committerKoichi Sasada <ko1@atdot.net>2021-12-10 00:56:25 +0900
commit9873af0b1a343dff6d1a8af4c813aa2c9ecc47d5 (patch)
treec400e0a544ff9150f28413fd9f27c6bc2a5de276 /trace_point.rb
parent88c804a6e720d85afbd6714113a85e6beb48c296 (diff)
downloadruby-9873af0b1a343dff6d1a8af4c813aa2c9ecc47d5.tar.gz
`TracePoint.allow_reentry`
In general, while TracePoint callback is running, other registerred callbacks are not called to avoid confusion by reentrace. This method allow the reentrace. This method should be used carefully, otherwize the callback can be easily called infinitely. [Feature #15912] Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
Diffstat (limited to 'trace_point.rb')
-rw-r--r--trace_point.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/trace_point.rb b/trace_point.rb
index db34e1b68d..85ebac9aa7 100644
--- a/trace_point.rb
+++ b/trace_point.rb
@@ -136,6 +136,22 @@ class TracePoint
end
# call-seq:
+ # TracePoint.allow_reentry
+ #
+ # In general, while a TracePoint callback is running,
+ # other registered callbacks are not called to avoid
+ # confusion by reentrance.
+ # This method allows the reentrance in a given block.
+ # This method should be used carefully, otherwise the callback
+ # can be easily called infinitely.
+ #
+ # If this method is called when the reentrance is already allowed,
+ # it raises a RuntimeError.
+ def self.allow_reentry
+ Primitive.tracepoint_allow_reentry
+ end
+
+ # call-seq:
# trace.enable(target: nil, target_line: nil, target_thread: nil) -> true or false
# trace.enable(target: nil, target_line: nil, target_thread: nil) { block } -> obj
#