Closed dusty-phillips closed 4 years ago
Ah, tests are not passing when --features=async. I'll see if I can fix it.
Yeah, unfortunately the way that the async APIs are you're essentially required to have a &mut
reference. Though the sync API doesn't have this same issue (as this PR highlights). The question then is: should the sync/async APIs differ with mutability w.r.t. listening for new incoming connections? I think I could be convinced since the stdlib TcpListener
s API uses shared references and I think its important to be able to drop in a MemorySocket
and MemoryListener
into places where the stdlib types are currently being used. Thoughts?
Yeah, I think it makes sense for the sync APIs to be drop in for the std::net ones.
I note that tokio's Listener::accept()
method requires an &mut,
but async_std's does not (somehow). So it's not possible to make memory-socket
a drop-in replacement simultaneously for both of them anyway. Ah, the joys of a split ecosystem.
If flume::Receiver::recv_async
could be made to not need a &mut
then we might be able to change the async api as well. In practice you should only have 1 Receiver (since it doesn't impl Clone
) so hopefully it doesn't cause too many issues.
Anyway, if you want to tweak your PR to only change the mutability of the sync api we can go ahead and get that merged at least.
Should be good to go now.
Thanks! I'll publish a new release shortly
The structs being emulated (TcpStream et al) are not &mut for the listening and accept methods, so it seems reasonable that memory-socket shouldn't be either. Since Flume channels don't require mutable references, it was easy to take them out. Tests pass; is there any reason not to do this?