[threads|interprocess] thread_locking_policy and process_locking_policy

Hello, I'm defining a class Locally Unique Identifier (see http://lists.boost.org/Archives/boost/2008/03/134088.php) that has a locking policy. This locking policy needs to define a mutex_type and a scoped_lock types. This could be null_locking_policy for monothreaded usage, thread_locking_policy for multi-threaded access and process_locking_policy for multi-process access. The problem is that when I try to initialize the scoped lock with a try_to_lock the types and variables are differents, even if both mùean the same. And so I need to add a function try_to_lock in the policy. struct thread_locking_policy { typedef boost::mutex mutex_type; typedef boost::mutex::scoped_lock scoped_lock; static const boost::try_to_lock_t try_to_lock() {return boost::try_to_lock;} }; struct process_locking_policy { typedef boost::interprocess::interprocess_mutex mutex_type; typedef boost::interprocess::scoped_lock<mutex_type> scoped_lock; static boost::interprocess::detail::try_to_lock_type try_to_lock() { return boost::interprocess::try_to_lock; } }; IMO we need to armonize the threads and interprocess synchronization interfaces. I don't know where these types and variables could be, but we need that both libraries use the same type and variable. Anyway, these trivial classes will be redone by each user defining a class that manage the synchronization in a wide context. Is there an interest in these locking policies classes. We can add recursive_thread_locking_policy and recursive_process_locking_policy . Where these classes could be placed. Why not in an new boost/sync directory? Please, let me know if there is a better solution already present on boost. Regards _____________________ Vicente Juan Botet Escriba

vicente.botet wrote:
That would interesting. This situation was caused because Interprocess was accepted after Boost.Thread was. Interprocess followed Howard Hinnant's thread proposal, so I couldn't reuse boost::scoped_lock, etc... Now that Boost.Thread follows the standard C++ thread library (which is heavily based on Howard's first proposal) it would be interesting to merge both. One of the problems of Boost.Thread reuse was that Boost.Thread required multithreading support (looking _REENTRANT or _MT defines) and in some systems that's not necessary since we can build a single threaded, process-shared system. I think this could be a good issue for Boost 1.36. Boost.Interprocess should start reusing available Boost.Thread resources (adapting them if necessary). Any thoughts on this Anthony? Regards, Ion

Ion Gaztañaga <igaztanaga <at> gmail.com> writes:
I think it would be a good idea. If we can come up with a framework that works for both boost.interprocess and boost.thread, this might be a good basis for a TR2 proposal, too. Anthony -- Anthony Williams Just Software Solutions Ltd - http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL
participants (3)
-
Anthony Williams
-
Ion Gaztañaga
-
vicente.botet