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
Every networking library ive ever used exposes the send function by a pointer or reference to the data that should be sent. Why is this not the case for this library? i can not understand why i need to copy messages and make extra allocations. Same applies for reading data from the socket. Why can i read it into a buffer?
The text was updated successfully, but these errors were encountered:
Because this allocation must exist somewhere since sending is not always immediate, sometimes data are kept in the outgoing queue. Most libraries do it internally. We decided to expose it to make it obvious and to put it into the external interface in order not to provide false sense of "zero-copying".
We're actually discussing possibilities of optimizing this part (see #96) but there is no solution without any drawbacks. For example, forcing to use Arc is even worse than forcing to use clone() if the environment is single-threaded. That's why both Rc and Arc exist. Copying of small data within one thread could be less expensive than doing thread-safe atomic increment on a multiprocessor system. We really want to provide a free choice of these possibilities, but the general solution is still in discussion phase, and I personally don't have much time to implement such things right now. Feel free to jump in.
As @agalakhov mentioned, there is an issue (#96) that tracks the change that would lift such a limitation in a library, so I think we can close this one (otherwise, it's really hard to keep track of things when they are discussed in separate issues).
Every networking library ive ever used exposes the send function by a pointer or reference to the data that should be sent. Why is this not the case for this library? i can not understand why i need to copy messages and make extra allocations. Same applies for reading data from the socket. Why can i read it into a buffer?
The text was updated successfully, but these errors were encountered: