Astron/Astron — pull request #212 by CFSworks (2014-05-03 01:39:12+00:00)
Title: Add threading to the Message Director

**PSA: This is a potentially breaking change!** Though the impact to the codebase is minimal, the introduction of a second thread in the process can cause nasty race conditions and other unsavory bugs to reveal themselves. This is a good thing in the long run, as it helps those bugs get squashed in development, but nevertheless this branch should not be merged carelessly.

Though everything here works 100% fine for me, I would highly recommend running the following tests:
1. Iterated unit testing (using `while make test; do echo; done` or similar)
2. Running Astron in your favorite thread debugger to find deadlocks and data races.
3. Running this branch as your primary version of Astron for development.

**That said, on to the summary of changes:**
This branch adds a second thread to the Astron process, which is a thread dedicated to handling MD routing. Rather than roles calling the route function directly, it runs in a separate thread (which can be disabled with `messagedirector/threaded: false` in the config.yml) that pulls messages out of a queue continuously. Either the main (ASIO) thread or the MD thread can write messages back to the queue.

In the future, the plan is to add a worker pool consisting of multiple threads that will deploy the routed messages to the roles in parallel with the MD thread. Currently, however, the MD thread itself delivers the message directly. This keeps the parallelism impact on most other components of the Astron stack to a minimum.