[thread] lockable traits and concepts classes adding proposal

Hello boosters , While writtig a generic library I have needed some lockable traits and concepts to be chacked with BCCL. If you think that these classes are of general use it will be a pleasure for me, if Anthony accepts, to included them on the Boost.Thread library. Otherwise I will left them in my Sync library. For the moment all is defined in a sync (as synchronization) namespace and directory but this is without importance. Attached a short introduction (in quickbook format- sorry I can not attach the html file) as well as the header files (which should with gcc 3.4 on cygwin) Of course all this is subject to discusion, naming and file structure changes, ... For each one of the mutex in the thread library, we need to * make the mutex inherit from the helper lock_traits_base or * have nested typedefs or * specialize each one of the traits templates As an external library I have do this in a non-intrusive way as for example: template<> struct timed_interface_tag<boost::mutex> { typedef hasnt_timed_interface_tag type; }; template<> struct reentrancy_tag<boost::mutex> { typedef non_recursive_tag type; }; template<> struct category_tag<boost::mutex> { typedef exclusive_lock_tag type; }; template<> struct scope_tag<boost::mutex> { typedef multi_threaded_tag type; }; But if included in the Thread library it will be better to use one of the intrusive methods. I have also defined other classes that could be of general interest. * A make_lockable class will make Lockable/ShareLocakble/UpgradeLocable the derived class depending on the Lock parameter. This class could be the base of a monitor class. It can be used as follows: class X : public make_lockable<boost::mutex> { } X x; unique_lock<X> lock(x); * a ..._synchronization_family set of classes that can be used as follows: template <class SyncFamily> message_queue; typedef message_queue<thread_synchonization_family> my_mt_message_queue; typedef message_queue<null_synchonization_family> my_st_message_queue; The null_synchonization_family needs a null_mutex and a null_condition classes. There is already something similar in Boost::Interprocess. * To finish, I'm working on a filter_matching_lockables meta-function which take as parameter a vector of lockables types and will filter the lockables types not satisfying a list of traits. The use shoul be somthing like typedef filter_matching_lockables<vector<boost::mutex, boost::recursive_mutex, ...>, mpl::and_<is_exclusive_lock<_>, mpl::not_<is_recursive_lock<_> > >::type candidates. and a find_best_lock which choose between the lockables given as parameter the best one following a given criteria. Of course, there is yet a lot of work to do, add lock concepts, lockable and lock concept traits, document, tests, document, tests ... between others. As you see there is nothing new, neither complex, only some helper classes making easier the construction of higher abstraction levels, and that currently are missing in boost. Have a good code reading and please let me know what do you think. _____________________ Vicente Juan Botet Escriba

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 16 May 2008 16:45 pm, vicente.botet wrote:
While writtig a generic library I have needed some lockable traits and concepts to be chacked with BCCL.
If you think that these classes are of general use it will be a pleasure for me, if Anthony accepts, to included them on the Boost.Thread library.
I haven't gone over your proposal in detail, but I for one agree some kind of traits for mutex classes would be useful. I had to do something similar, defining a mutex_properties template class and giving specializations for all the boost.thread mutex types: http://www.comedi.org/projects/libpoet/boostbook/doc/boostbook/html/poet/mut... - -- Frank -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFILgEx5vihyNWuA4URAsCCAJ9ZcCM6QYQzHMAiNFM2Zu/sFW7ZYACgxwxx N+9r9953cUMnXnRYfRAwuXM= =zAfU -----END PGP SIGNATURE-----

Frank Mori Hess <frank.hess@nist.gov> writes:
On Friday 16 May 2008 16:45 pm, vicente.botet wrote:
While writtig a generic library I have needed some lockable traits and concepts to be chacked with BCCL.
If you think that these classes are of general use it will be a pleasure for me, if Anthony accepts, to included them on the Boost.Thread library.
I haven't gone over your proposal in detail, but I for one agree some kind of traits for mutex classes would be useful. I had to do something similar, defining a mutex_properties template class and giving specializations for all the boost.thread mutex types:
http://www.comedi.org/projects/libpoet/boostbook/doc/boostbook/html/poet/mut...
I hadn't thought about it before Vicente's suggestion, but it could be useful. Anthony -- Anthony Williams | Just Software Solutions Ltd Custom Software Development | http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 30 May 2008 06:39 am, Anthony Williams wrote:
Frank Mori Hess <frank.hess@nist.gov> writes:
On Friday 16 May 2008 16:45 pm, vicente.botet wrote:
While writtig a generic library I have needed some lockable traits and concepts to be chacked with BCCL.
If you think that these classes are of general use it will be a pleasure for me, if Anthony accepts, to included them on the Boost.Thread library.
I haven't gone over your proposal in detail, but I for one agree some kind of traits for mutex classes would be useful. I had to do something similar, defining a mutex_properties template class and giving specializations for all the boost.thread mutex types:
http://www.comedi.org/projects/libpoet/boostbook/doc/boostbook/html/poet/ mutex_properties.html
I hadn't thought about it before Vicente's suggestion, but it could be useful.
Now I feel ignored: http://lists.boost.org/threads-devel/2007/12/0284.php :) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFIQE5D5vihyNWuA4URAphUAJ40p3iPYvA2sJ4aowlkFq6xpvt/TwCdGiwQ YKlfPHRUPOsLo8DhINaLYR8= =y5Z0 -----END PGP SIGNATURE-----

Frank Mori Hess <frank.hess@nist.gov> writes:
On Friday 30 May 2008 06:39 am, Anthony Williams wrote:
Frank Mori Hess <frank.hess@nist.gov> writes:
On Friday 16 May 2008 16:45 pm, vicente.botet wrote:
While writtig a generic library I have needed some lockable traits and concepts to be chacked with BCCL.
If you think that these classes are of general use it will be a pleasure for me, if Anthony accepts, to included them on the Boost.Thread library.
I haven't gone over your proposal in detail, but I for one agree some kind of traits for mutex classes would be useful. I had to do something similar, defining a mutex_properties template class and giving specializations for all the boost.thread mutex types:
http://www.comedi.org/projects/libpoet/boostbook/doc/boostbook/html/poet/ mutex_properties.html
I hadn't thought about it before Vicente's suggestion, but it could be useful.
Now I feel ignored:
Sorry, I'd forgotten about that post of yours. Too much happens in 6 months. Anthony -- Anthony Williams | Just Software Solutions Ltd Custom Software Development | http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

----- Original Message ----- From: "Anthony Williams" <anthony.ajw@gmail.com> To: <boost@lists.boost.org> Sent: Friday, May 30, 2008 12:39 PM Subject: Re: [boost] [thread] lockable traits and concepts classes addingproposal
Frank Mori Hess <frank.hess@nist.gov> writes:
On Friday 16 May 2008 16:45 pm, vicente.botet wrote:
While writtig a generic library I have needed some lockable traits and concepts to be chacked with BCCL.
If you think that these classes are of general use it will be a pleasure for me, if Anthony accepts, to included them on the Boost.Thread library.
I haven't gone over your proposal in detail, but I for one agree some kind of traits for mutex classes would be useful. I had to do something similar, defining a mutex_properties template class and giving specializations for all the boost.thread mutex types:
http://www.comedi.org/projects/libpoet/boostbook/doc/boostbook/html/poet/mut...
I hadn't thought about it before Vicente's suggestion, but it could be useful.
Hi Frank, Anthony, Have you taken the time to see my proposal? It will be a pleasure for me to know what do you think. Ion, because this is also related the Interprocess.Sync library your advice will be really apreciated. Best Vicente

"vicente.botet" <vicente.botet@wanadoo.fr> writes:
Frank Mori Hess <frank.hess@nist.gov> writes:
On Friday 16 May 2008 16:45 pm, vicente.botet wrote:
While writtig a generic library I have needed some lockable traits and concepts to be chacked with BCCL.
If you think that these classes are of general use it will be a pleasure for me, if Anthony accepts, to included them on the Boost.Thread library.
I haven't gone over your proposal in detail, but I for one agree some kind of traits for mutex classes would be useful. I had to do something similar, defining a mutex_properties template class and giving specializations for all the boost.thread mutex types:
http://www.comedi.org/projects/libpoet/boostbook/doc/boostbook/html/poet/mut...
I hadn't thought about it before Vicente's suggestion, but it could be useful.
Hi Frank, Anthony,
Have you taken the time to see my proposal? It will be a pleasure for me to know what do you think.
The current implementation of boost.thread provides the boost::is_mutex_type (in boost/thread/locks.hpp), which is currently used to decide whether lock(a,b) is a call to lock two mutexes or to lock a range. The trait is true if the type provides lock(), unlock() and try_lock() member functions. At some point I will add another trait which includes timed_lock, and another for shared_lock. Recursive vs non-recursive cannot be detected, so would have to be implemented either by specialization of a traits class (as per libpoet) or by a member flag (such as mutex::is_recursive). Anthony -- Anthony Williams | Just Software Solutions Ltd Custom Software Development | 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
-
Frank Mori Hess
-
vicente.botet