Boost logo

Boost :

Subject: Re: [boost] [thread] Integration with Chrono and DateTime
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2012-10-20 12:43:26


Le 20/10/12 16:41, Andrey Semashev a écrit :
> 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.
The approach seems interesting. I have however some questions and remarks.

Where the types detail::thread_duration and detail::thread_time are
defined? I didn't find it in the attached files.

I don't like the idea that we need to change Boost.DateTime neither
Boost.Chrono. I will prefer that the Boost.DateTime and Boost.Chrono
specific stay in a specific Boost.Thread file. DO you think it is
possible to don't change these two libraries? if yes, how?

By default the Boost.Chrono interface should be provided including the
specific file. Of course it should be possible to disable its inclusion.

I don't see why thread_time_traits need the second parameter. Partial
template specialization seems enough to me, isn't it?
> 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.
If no body is against removing it I'm all for.
>
> 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.

This could be seen as an advantage but also as an drawback as we are
multiplying the interfaces.
I don't want the timed_lock to be possible with Boost.Chrono. How could
this be achieved?
>
> 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.
IMO something like this could be introduced. I could say more once I
have some of the answers to my previous questions.

Thanks for the work done,
Vicente


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk