marigold-dev / pollinate

A platform agnostic library for P2P communications using UDP and Bin_prot
22 stars 2 forks source link

Move background processes to an Lwt.async context #52

Open rosalogia opened 2 years ago

rosalogia commented 2 years ago

This PR tries to address #51 by moving certain "background processes" such as sending messages for failure detection and dissemination out of the server and into an Lwt.async call. This means the server can block as much as it wants waiting for new messages and handling them before continuing. The original reason for this was to remove the fixed interval between server iterations due to the fact that messages were being received/handled in a separate thread which was not being awaited. However, I have found that this approach does not actually allow us to remove the fixed interval. It is still necessary for the interval to be there in the function called with Lwt.async, or things begin to stall. I am not sure if this change is desirable.