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
23
lib/pp.rb
23
lib/pp.rb
@ -93,11 +93,24 @@ class PP < PrettyPrint
|
|||||||
end
|
end
|
||||||
# :startdoc:
|
# :startdoc:
|
||||||
|
|
||||||
@sharing_detection = false
|
if defined? ::Ractor
|
||||||
class << self
|
class << self
|
||||||
# Returns the sharing detection flag as a boolean value.
|
# Returns the sharing detection flag as a boolean value.
|
||||||
# It is false by default.
|
# It is false (nil) by default.
|
||||||
attr_accessor :sharing_detection
|
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
|
end
|
||||||
|
|
||||||
module PPMethods
|
module PPMethods
|
||||||
|
Loading…
x
Reference in New Issue
Block a user