[asio] Order of handler processing within a strand

Is there any guarantee about the order of the processing of handlers within a given strand? If, from one thread, I post several handlers in the same strand to the io_service, will those handlers necessarily be run in the order of the post calls? Or am I only guaranteed that they won't be run concurrently? Austin Bingham

Hi Austin, On Mon, 4 Dec 2006 14:03:08 +0000 (UTC), "Austin Bingham" <abingham@arlut.utexas.edu> said:
Is there any guarantee about the order of the processing of handlers within a given strand? If, from one thread, I post several handlers in the same strand to the io_service, will those handlers necessarily be run in the order of the post calls?
Yes, that is the intent (although it isn't currently specified in the documentation). Note that the guarantee only applies to strand::post(). If you use strand::dispatch() it may execute the handler immediately and break the ordering. Cheers, Chris

Yes, that is the intent (although it isn't currently specified in the documentation). Note that the guarantee only applies to strand::post(). If you use strand::dispatch() it may execute the handler immediately and break the ordering.
Excellent, thanks :) Along those lines, has there been any thought about separating the io_service functionality into a separate library? A robust, tested work-thread queue system has lots of applications aside from the (relatively) narrow purview of asio. People might be more likely to find and use it if it's advertised as a more general purpose tool. Just a thought. Austin Bingham

Hi Austin, On Tue, 5 Dec 2006 13:42:09 +0000 (UTC), "Austin Bingham" <abingham@arlut.utexas.edu> said:
Along those lines, has there been any thought about separating the io_service functionality into a separate library? A robust, tested work-thread queue system has lots of applications aside from the (relatively) narrow purview of asio. People might be more likely to find and use it if it's advertised as a more general purpose tool. Just a thought.
The implementation of io_service is coupled to I/O, so I don't think it's appropriate to separate it out. However, an interface that consists of just post/dispatch/run etc could certainly be implemented as a separate library, if somebody wanted to do that. Cheers, Chris
participants (2)
-
Austin Bingham
-
Christopher Kohlhoff