-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
When marshaling objects that have reference semantics, having a clone / inplace parameter for the (un)marshal generics might be handy.
The pseudocode below illustrates a call to marshal(), where cloning is not necessary and another call to unmarshal() where it is necessary.
g <- function() {
x_marshaled <- callr::r({
x <- f(...)
marshal(x, clone = FALSE)
})
x_unmarshaled <- unmarshal(x_marshaled, clone = TRUE)
y <- h(x_unmarshaled)
return(list(x_marshaled, y))
}To stay on the safe side, marshal methods for objects with reference semantics should always clone by default and not modify th object that is being marshaled in-place. Because marshal() if often called right before sending the object to another process, it might be worth to optimize the special case where in-place modifications are allowed (or in general, the object that is being marshaled is not being further used).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels