
On Fri, 30 Dec 2005 08:29:33 +1100 (EST) Christopher Kohlhoff <chris@kohlhoff.com> wrote:
If I do as Peter suggested and check for the absence of BOOST_HAS_THREADS you probably don't need to do anything.
You'd have to do that in the demuxer and any other place as well. Maybe you should define a null mutex type for use in those cases. That way, any code that uses synchronization primitives will automatically do nothing.
However, the control flow for the demuxer will be executed in a single thread, and should not be doing anything with synchronization primitives.
Actually the demuxer is partly intended to provide you with a thread-safe way of passing work across threads, i.e. demuxer.post() can be called from any thread to invoke a function in the single thread that is calling demuxer.run().
Look at the implementation of epoll_reactor though. There are a few issues with it, especially when you have multiple threads in the run() function.
Part of what bothers me is that boost is a modern C++ library, and as such has many tools to allow different practices, yet we still use IFDEFs and blindly insert synchronization primitives in places where they are not needed.
I'm going to talk about this more in another reply, but I believe that the current interfaces can be implemented to be thread-safe without using mutexes.
OK, thanks! I look forward to it. BTW, I am trying to reimplement (using asio) a major component in wide use everyday in a bunch of networking applications. I'm running out of time, and I'm actually home sick right now, so I may not finish. Anyway, I thought it would give me some good ground on which to base a review. I will possibly have issues that may not pertain to the review itself. Can I send them to your private email address, or should I keep them here? Again, thanks for the hard work on asio.