Re: You provide gun, I provide foot.

In any case, the boost libs still rock! Maybe I'll dig a little deeper and make a proposal; after April 15th of course!
After investigating various ways to solve my difficulties from previous posts (see http://lists.boost.org/boost-users/2005/04/11119.php and http://lists.boost.org/boost-users/2005/04/11120.php), I've settled on the following solution. I believe the changes contained in the following patch (to http://www.boost.org/libs/thread/example/recursive_mutex.cpp) enable more traditional/procedural mutex operation (i.e. un-scoped locks). I think my COM component is saved! diff -u recursive_mutex.cpp recursive_mutex_key.cpp --- recursive_mutex.cpp Mon Apr 18 08:52:07 2005 +++ recursive_mutex_key.cpp Mon Apr 18 09:03:03 2005 @@ -13,19 +13,27 @@ #include <boost/thread/thread.hpp> #include <iostream> +#define recursive_mutex_key boost::detail::thread::lock_ops<boost::recursive_mutex> + class counter { public: counter() : count(0) { } int add(int val) { - boost::recursive_mutex::scoped_lock scoped_lock(mutex); + int retval; + recursive_mutex_key::lock(mutex); count += val; - return count; + retval = count; + recursive_mutex_key::unlock(mutex); + return retval; } int increment() { - boost::recursive_mutex::scoped_lock scoped_lock(mutex); - return add(1); + int retval; + recursive_mutex_key::lock(mutex); + retval = add(1); + recursive_mutex_key::unlock(mutex); + return retval; } private: Feedback greatly appreciated, Dino P.S. Taxes all done, ya!
participants (1)
-
C. Michailidis