On 13-04-23 07:51 AM, Alexander Stavonin wrote:
Second response not about deep copy but about simplifying deep copy
operation. Actually, I understood the reason of deep-copy-only
conversions immediately after sending the question. And "big source code
overhead from nothing" means: we almost always have to write conversion
manually rather than do it automatically. The proposal is adding auto
conversion operation between Shared and Owned boxes. May be it should
looks like C++ copy or move constructors. In case of move conversion,
the operation can be allowed only if there is only one Shared box is
owned a value. For copy conversion it can make deep object copy
automatically.

Just because an @-box has only one owner doesn't mean its substructures don't branch. We have to trace through all its pointed-to values performing the same action. That's a deep copy at any shared edges.

We could try to implement deriving(Clone) to perform this operation sometimes (when running on a runtime where the managed and owned heaps are drawn from the same underlying allocator, or a compatible one). When the managed heap is specialized and pinned to a task, in general, it's not possible: the sending task may exit, invalidating all of its managed memory immediately.

Beyond that, this is (largely) the same question you asked on apr 19 ("Passing managed value to task") so the answer is (largely) the same: we have attributes #[auto_encode] and #[auto_decode] that will serialize and deserialize values "fully" and can be used for passing managed values between tasks.

-Graydon


_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to