1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

pp is ractor-ready.

`@sharing_detection` is only one obstruction to support pp on
non-main ractors, so make it ractor-local.
This commit is contained in:
Koichi Sasada 2020-12-22 17:07:23 +09:00
parent 034c19ce28
commit cae8bbfe62
Notes: git 2020-12-22 23:32:44 +09:00

View file

@ -93,11 +93,24 @@ class PP < PrettyPrint
end
# :startdoc:
@sharing_detection = false
class << self
# Returns the sharing detection flag as a boolean value.
# It is false by default.
attr_accessor :sharing_detection
if defined? ::Ractor
class << self
# Returns the sharing detection flag as a boolean value.
# It is false (nil) by default.
def sharing_detection
Ractor.current[:pp_sharing_detection]
end
def sharing_detection=(b)
Ractor.current[:pp_sharing_detection] = b
end
end
else
@sharing_detection = false
class << self
# Returns the sharing detection flag as a boolean value.
# It is false by default.
attr_accessor :sharing_detection
end
end
module PPMethods