in reply to "Web server embedding" (Mojolicious docs)
There are two approaches to running two event loops in parallel.
The approach you already outlined is to set up a "timer" and periodically run the "other" event loop. This gets you the advantage of running single-threaded, without race conditions at the price of high constant CPU load.
The other one is to run each event loop in its own thread, which brings you the advantage and disadvantage that both event loops run in parallel. You get all the advantages of near-time event processing coupled with all the disadvantages of threads, like race conditions etc.
If you are lucky you can make the secondary event loop write to a socket that the primary event loop listens on. This way, you can channel all the events from the secondary event loop to the primary event loop.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: "Web server embedding" (Mojolicious docs)
by vr (Curate) on May 11, 2017 at 16:33 UTC |