belaban/TaskDistribution

Threading issue for receive & viewAccepted methods

Closed this issue · 1 comments

mkurt commented

Hi,
Thanks for this demo. Are there any threading issues between receive and viewAccepted methods while multiple peers are connected? I'm confused about rank and cluster_size variables specifically. Can these two methods be called simultaneously?

Hi @mkurt

in a default stack, views are delivered as a multicast message from the coordinator. The viewAccepted() callback is guaranteed to be invoked by one thread only. Messages can be received concurrently.

Note that TaskDistribution is just a demo. As you guessed, there should probably be synchronization between receive() and viewAccepted() wrt variables rank and cluster_size. If you're up to, submit a PR.
For more info on message delivery semantics see [1].
Cheers,

[1] http://www.jgroups.org/manual4/index.html#_message_delivery_and_ordering