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
Sending messages should not require ownership of the message being sent.
For example, the send method on Process has the following signature:
pubfnsend(&self,message:M);
This should be taking a reference of M:
pubfnsend(&self,message:&M);
Though this would be a breaking change.
One solution which may keep it as non-breaking would be to take impl AsRef<M>.
Though I'm not sure if every implementation of AsRef is compatible to ser/de in bincode. There is also the possibility of the Borrow trait, though I'm also not sure if everything implemented is compatible with bincode.
The text was updated successfully, but these errors were encountered:
tqwewe
changed the title
Send functions should take a reference of message Msend functions should take a reference of message MMar 1, 2023
tqwewe
changed the title
send functions should take a reference of message Msend functions should take a reference of message &MMar 1, 2023
The reason why we don't take a reference is that some resources are moved out of the process into the message during serialization. This makes it unsafe to serialize them two times. I admit that this is not the most elegant way of coupling things, but I couldn't come up with a better solution.
We could solve this for example by just cloning resources during serialization and move the cloned ones into the message. This however would require all resources to be Clone. I'm not sure if this is true for all resources (e.g. listening socket) that can be sent between processes.
Hmm I see, I think it might be worth looking into, since giving a reference when sending messages would strip out a bunch of cloning I would imagine. I'm not sure which resources might not be Clone. TcpListener doesn't seem to even be Serializable.
I like the solution of cloning within the serialization implementation, since most resources are just integer identifiers.
Sending messages should not require ownership of the message being sent.
For example, the send method on
Process
has the following signature:This should be taking a reference of
M
:Though this would be a breaking change.
One solution which may keep it as non-breaking would be to take
impl AsRef<M>
.Though I'm not sure if every implementation of AsRef is compatible to ser/de in bincode. There is also the possibility of the
Borrow
trait, though I'm also not sure if everything implemented is compatible with bincode.The text was updated successfully, but these errors were encountered: