Juniper/contrail-controller — pull request #243 by tkarwa (2014-02-05 00:51:15+00:00)
Title: All boost async operations need to occur in the context of the same task...

... i.e.

the task that is executing run(). In our case, its the main task.
io_service.post() guarantees that the handler will only be called in a thread
in which the run(), run_one(), poll() or poll_one() member functions is
currently being invoked. But, there are no guarantees wrt to ordering.
Using strand.post() guarantees the thread and also has some ordering
guarantees. In our case, we have the main-task and sm-task that are competing.
Intuitively, it makes sense to enforce ordering of callbacks since the events
triggering the callbacks are ordered and this is a state-machine where the same
event in a different state could cause issues. So, we will use strand.post().
Also, adding a small macro to check if we are running in the context of the
main-task and using it to check that we are in the right context while
executing the boost-async calls.