marigold-dev / pollinate

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

Unnecessary sleep time in server #51

Open rosalogia opened 2 years ago

rosalogia commented 2 years ago

Currently we require a 0.001 sleep time between server iterations due to the fact that we handle message reception/processing in a secondary thread. This means that the recursive function that acts as the server has nothing to wait for between runs, and thusly sort of spins out of control if there is no sleep time between recursive calls. This is not necessarily the correct design. The reason we handle message reception/processing in a secondary thread is because the server is responsible for triggering some other periodic behaviours such as dissemination and failure detection, and these must fire regularly even if a message is not received. The real solution is to make things like dissemination and failure detection asynchronous with Lwt.async, have the server wait for new messages, and handle message processing in a secondary thread.

RELATED PRs: