You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, trying to spawn a process requires you to clone captured data if you'd like to use it after the spawn. But because encoding data only requires a & reference, cloning should not be required.
Eg:
#[derive(Serialize,Deserialize)]structFoo{}// Doesn't implement clonefnmain(){let foo = Foo{};Process::spawn(&foo, |foo, _:Mailbox<()>| { ...});// Fails, Deserialize is not implemented for `&Foo`, only `Foo`.Process::spawn(foo, |foo, _:Mailbox<()>| { ...});Process::spawn(foo, |foo, _:Mailbox<()>| { ...});// fails, because foo was moved}
It would be nice if spawn worked with both &foo and foo, so the change would not be breaking in any way.
The text was updated successfully, but these errors were encountered:
The issue are resources, they need to be owned when encoded. We could though explicitly clone them during serialisation.
There was also an idea of special serializers that send a reference to the process' memory, so that copies are completely avoided. In this case everything that is sent needs to be consumed, because now some other process owns part of your memory. To be forward compatible, I decided that captured data is owned. Not sure if we are getting this feature soon though.
If you serialize &Foo, can you deserialize it as Foo? What I mean is, from what are you borrowing the Foo inside the other process.
I see, that makes sense if the data really is semantically being moved to another process. I often imagined it was copied with serialization, but forward compatible reasons this makes sense.
Currently, trying to spawn a process requires you to clone captured data if you'd like to use it after the spawn. But because encoding data only requires a
&
reference, cloning should not be required.Eg:
It would be nice if
spawn
worked with both&foo
andfoo
, so the change would not be breaking in any way.The text was updated successfully, but these errors were encountered: