From: Jeremy Maitin-Shepard (jbms_at_[hidden])
Date: 2003-06-24 16:18:28
Jeff Garland wrote:
> I think that it is broader than sockets. The thread library, for
> example, uses something that basically amounts to timeval in
> some cases. Finally, if someone wanted to use a different socket
> library (especially since boost.socket isn't in boost) why make
> them rewrite this code?
AFAIK, timeval is used only by select. Indeed, it was incorrect for
me to state that select is used only in regards to sockets. On
unix-like platforms, it can be used to check the status of any file
descriptor, but on Win32 platforms, it is available only as part of
the winsock library and is usable only on file descriptors that
correspond to sockets.
The thread library as of boost 1.30 does provide a struct xtime, which
is similar to timeval, except that xtime represents a time, while
timeval represents a time duration. The documentation for the thread
library suggests, however, that xtime is intended as a temporary
solution only, and that it will be replaced by a more complete boost
time library. I do not know whether William E. Kempf has already
planned to make this change in the next revision of the thread
library, but it seems that the Boost date/time library is precisely
the library that should replace xtime; thus there is no need for
conversions between xtime and ptime.
On Tue, Jun 24, 2003 at 10:22:19AM -0400, Stefan Seefeld wrote:
> indeed. select() is useful for many things. It has been used as
> a replacement for nanosleep in case the latter was not provided,
> it is used to test the non-blocking readability/writability of
> file descriptors, and it is at the center of most event-driven
> applications, i.e. the 'main loop'.
Note that the Boost thread library provides a sleep function with the
possibility of nanosecond resolution.
I suppose,though, that in the absence of a Boost socket library and/or
other boost libraries to portably check the state of non-socket file
descriptors, this conversion could be useful.
- Jeremy Maitin-Shepard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk