Battousai: if I'm getting your class to thread mapping concept right, then m_bRunning is not correctly reset if the thread ends itself.
Quote:Original post by the_edd
Efficient implementations of the primitives in boost threads are possible on Windows (though the Windows API might not be used) else C++ wouldn't be standardising on it.
Implementation details, especially platform specific ones, were not even considered by the C++ standarization committee.
Quote:Original post by the_edd
Of course, possible != available, necessarily.
It is impossible to efficiently implement condition variables on pre-Vista, since they are unsupported by the kernel. A
good CV implementation on XP (ie. one that will never deadlock and is well balanced in all situations), relying on semaphores and mutexes, is surprisingly complex and dead inefficient. Have a look at how Boost::threads implements it.
While native kernel CVs exist in Vista and above, their use will lead to code that behaves radically differently on XP, performance wise.
Quote:Original post by the_edd
I tend to find the the Windows threading functionality far stranger e.g. the naming of CRITICAL_SECTION, the way you have to bend over backwards to use WaitForMultipleObjects with more than MAXIMUM_WAIT_OBJECTS handles, the special meanings for Sleep() with special values as arguments. To each their own though, I guess.
I agree that Windows threading is a bit bizarre. But Windows representing 90%+ of the PC market, it should be the primary driving platform for standarization. Especially for a concept which is so OS dependent as threading.
Quote:Original post by the_edd
I can't say I've ever found the need to do that. I tend to design things so that either a thread is doing some work that I want done ASAP or waiting (idling) for that work to arrive.
There are many scenarios where lowering the priority can be useful. It gives valuable hints to the scheduler on how to assign time slices amongst a set of candidate threads. An example would be a realtime 3D application that requires entirely smooth motion, with a background network thread that will periodically use a lot of CPU. Lowering the latter threads' priority can help to avoid sudden glitches or lags in the animation thread. It is also very important for single CPU systems, or multi-CPU scenarios with fixed core affinities.
Anyway, this is probably a bit offtopic :)