
On Wednesday 17 October 2012 07:57:33 Vicente Botet wrote:
Could you show the interface the class B look like with this traits?
Ok, I started experimenting with the idea and have put together a sort of proof of concept. Please, find attached the patch that modifies boost::timed_mutex for POSIX systems and also adds the necessary bits to Boost.DateTime. The new headers are attached separately. A few words of summary: 1. The new files are: boost/date_time/thread_support.hpp, boost/thread/detail/thread_time_traits.hpp, boost/thread/posix/time_units.hpp. 2. I had to make a few includes in thread_time_traits.hpp - the time_units.hpp for the current platform, which includes config.hpp and cstdint.hpp. These headers are included by DateTime, Chrono and Thread anyway, so harm is really done. 3. I removed explicit support for boost::xtime. This type is long deprecated so I was wondering if there is need for supporting it at all. If there is, it can be plugged in with another thread_time_traits specialization. 4. A nice outcome of the modification is that timed_mutex interface is now unified with regard to time units, so it is now possible to do: mtx.try_lock_for(boost::posix_time::seconds(2)); which was previously only possible with Chrono units. 5. The thread_time_traits interface appeared quite concise (just one conversion function). I also introduced a tag typedef just in case it is needed for dispatching somewhere, but it's not needed now. I will remove it if no such need arises. Please tell me what you think about it.