I am experimenting with the libevent library. I defined a few events and I do not create any threads in my code.
My question is, if a few events can access/modify the same shared struct, do I need a mutex to lock the critical section to avoid race condition? Or is libevent designed in a way that events can only be executed consecutively, never concurrently?
Notes:
- But of course the question is only about the case in which my events do not spawn new threads themselves
- My concern is mainly from my experience with JavaScript: JavaScript uses event loop design as well but we can still corrupt data even if there is only one thread. The reason is that JavaScript can, as I understand, "pause" the execution of one event and start a second event, then resume the paused event. If the pause happens right between lines that modify a shared object, it can corrupt my object.
- RTFM already but does not find the definite answer I am looking for