Project

General

Profile

Actions

Feature #18894

open

Object#make_shareable

Added by chucke (Tiago Cardoso) over 1 year ago. Updated 10 months ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:109119]

Description

I'm proposing a callback method for when one calls Ractor.make_shareable(obj), the same way Marshal.dump(obj) calls obj.marshal_dump.

A lot of use cases in the wild involve a quick initialization of an object, only for some more heavy initializattion to be lazily called the first time an operation is called. An example in stdlib is Resolv::Hosts, which calls lazy_initialize on certains calls to resolve a name. Given that Resolv has a default resolver, this is unusable in ractors, due this "lazy" thing. Having a callback would allow to eager-load such an object, thereby making the default resolver usable with ractors.

Updated by AMomchilov (Alexander Momchilov) 10 months ago

#make_shareable sounds like it's an alias for Ractor.make_shareable. Callbacks tend to be past tense, how about #made_shareable?

Actions

Also available in: Atom PDF

Like0
Like0