Closed vakaras closed 4 years ago
I merged #88, would you be able to rebase on that? Thanks.
I merged #88, would you be able to rebase on that? Thanks.
Thank you for merging #88! I have rebased this PR.
Looks good, I skimmed and it matches my expectation. I did have one question, which I added inline.
For some reason, I do not see your question. (I also have not received any notification about it.)
@vakaras very strange...
You have one Synchronize
for the entire channel. I believe synchronization should happen on a message basis, no? So, you would have one Synchronize
value per message. When you recv a message, you apply the synchronization received for that message.
Good point. Since mpsc
supports multiple producers, we need to synchronize on a message basis. Thanks for pointing this out! I will update the PR.
Since the documentation claims that mpsc
channels preserve the order of the messages, I changed the code to have one synchronization point for senders and a synchronization point per message for receivers. As a result, if thread t1
managed to send m1
before t2
sent m2
, the thread that received m2
will know that m1
was already sent and received. However, the receiver of m1
will know nothing about m2
.
Adds Loom mocks for
std::sync::mpsc
. Also, adds unimplemented stubs forstd::sync::barrier
that the code that depends on them could be at least compiled.Note: This PR includes the changes from #88, so you probably want to merge it first. cc: @pop