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:
parent
034c19ce28
commit
cae8bbfe62
Notes:
git
2020-12-22 23:32:44 +09:00
1 changed files with 18 additions and 5 deletions
23
lib/pp.rb
23
lib/pp.rb
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue