Boost logo

Boost Users :

From: Johan Råde (rade_at_[hidden])
Date: 2008-04-21 11:29:47


Jeff Garland wrote:
>
>
> On Sun, Apr 20, 2008 at 12:49 AM, Anthony Williams
> <anthony_w.geo_at_[hidden] <mailto:anthony_w.geo_at_[hidden]>> wrote:
>
> Johan Råde <rade_at_[hidden] <mailto:rade_at_[hidden]>> writes:
>
> > I want to do a timed join, with a relative time of 0.1s.
> > I can not figure out from the docs how to do this.
> > I find the prototypes somewhat mystifying:
> >
> > bool timed_join(const system_time& wait_until);
> >
> > template<typename TimeDuration> bool timed_join(TimeDuration
> const& rel_time);
> >
> > What is system_time?
> > What should TimeDuration be?
>
> system_time is declared in boost/thread/thread_time.hpp: it is a
> typedef to
> boost::posix_time::ptime from the date-time library.
>
> TimeDuration is any boost date-time
> duration. e.g. boost::posix_time::milliseconds
>
> You are not the only person to notice the missing docs for the timeout
> stuff. It's on my list of things to add.
>
>
> There's some examples of how to construct these types on the boost
> date-time docs:
>
> http://www.boost.org/doc/libs/1_35_0/doc/html/date_time/posix_time.html#date_time.posix_time.time_duration
>
> You can use time_duration, but really the easy way is to construct from
> the 'count types'": milliseconds, nanoseconds, etc.
>
> Jeff

Thanks for the help.
I had never used the Boost.DateTime library before and hadn't realized
that the Boost.Thread library interface depends on the Boost.DateTime library.

Boost.DateTime looks like an excellent library.
I will make more use of it in the future.

A minor annoyance with Boost.DateTime:

boost::posix_time::milliseconds is a bit too verbose for my taste,
while just milliseconds is too brief.
posix_time::milliseconds seems just right.

If posix_time had been a class, then you could have written

    using boost::posix_time;

    ... posix_time::milliseconds ...

But since posix_time is a name space that can not be achieved.

Is there any way in C++ of bringing the name of namespace into the global scope
without bringing every name inside the namespace into the global scope?

--Johan

>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net