PARSEC main loops

I’m actually setting up a simple p2p network on virtual machines to test the PARSEC.

I need two main threads, one that has an infinite send loop and one with an infinite receive loop. The send loop takes peers at random and send create_gossip, then waits for the response.

The other thread waits for requests and sends response…

Are there example implementations somewhere? The integration test run everything in the same thread as far as I know.

Do these threads need to block each other?

If they don’t block, it might happen that two peers connect to each other in both loops at the same time. … This might give racing conditions


Not at the moment. However, we’ll be integrating Parsec into our Routing library fairly soon, and then the answer will be yes. :slight_smile:

Parsec isn’t inherantly thread-safe, so you’ll need to treat a Parsec instance as per any similar shared state and protect it with e.g. mutexes.


Hi @Andre , that is awesome that you tried to make a toy program to use Parsec.

Did you bring it to maturity eventually?

Feel free to share any example code. Any Parsec example code would help greatly to illustrate Parsec’s use, right now there’s only the reference implementation repo’s