↑ ↓ ← → Hannes <Hannes_member pathlink.com>
writes:
How do I sleep for a given number of milliseconds?
↑ ↓ ← → "Walter Bright" <newshound digitalmars.com>
writes:
"Hannes" <Hannes_member pathlink.com> wrote in message
news:diuepu$2ebg$1 digitaldaemon.com...
How do I sleep for a given number of milliseconds?
std.c.time.msleep()
↑ ↓ ← → Bruno Medeiros <daiphoenixNO SPAMlycos.com>
writes:
Walter Bright wrote:
"Hannes" <Hannes_member pathlink.com> wrote in message
news:diuepu$2ebg$1 digitaldaemon.com...
How do I sleep for a given number of milliseconds?
std.c.time.msleep()
usleep? I mean, shouldn't std.c.time be just a wrapper for C's time.h ?
--
Bruno Medeiros - CS/E student
"Certain aspects of D are a pathway to many abilities some consider to
be... unnatural."
↑ ↓ ← → Sean Kelly <sean f4.ca>
writes:
In article <dj0022$30lh$1 digitaldaemon.com>, Bruno Medeiros says...
Walter Bright wrote:
"Hannes" <Hannes_member pathlink.com> wrote in message
news:diuepu$2ebg$1 digitaldaemon.com...
How do I sleep for a given number of milliseconds?
std.c.time.msleep()
usleep? I mean, shouldn't std.c.time be just a wrapper for C's time.h ?
I think the C headers in Phobos are more representative of the C headers in DMC
than they are a strict adherence to the C standard. The obvious problem being
that while extensions are fine when implementing someone else's standard, they
set a dangerous precedent when establishing your own--does the presence of
msleep in std.c.time mean that all D implementations need that function there?
I assume since these headers are in std.c it should be apparent that that they
are an implementation of the C spec and any extensions are obviously
non-portable, but a D programmer without a C background may not know which
functions are standard and which are not. The C headers in Ares are a strict
implementation of the C standard (with the exception of alloca and one or two
others--clearly marked by a version(DigitalMars)) and are fairly complete.
They're available here if anyone wants them:
http://svn.dsource.org/projects/ares/trunk/src/ares/std/c/
I've eyeballed the headers in DMC and everything seems to be supported, though
there may be some gaps with GDC.
I'll see about submitting a sleep function for std.thread--the implementations
for Windows and most Unices are quite short.
Sean
↑ ↓ ← → Bruno Medeiros <daiphoenixNO SPAMlycos.com>
writes:
Sean Kelly wrote:
In article <dj0022$30lh$1 digitaldaemon.com>, Bruno Medeiros says...
Walter Bright wrote:
"Hannes" <Hannes_member pathlink.com> wrote in message
news:diuepu$2ebg$1 digitaldaemon.com...
How do I sleep for a given number of milliseconds?
std.c.time.msleep()
Now that's pretty strange. Should std.c.time contain sleep, msleep,
usleep? I mean, shouldn't std.c.time be just a wrapper for C's time.h ?
I think the C headers in Phobos are more representative of the C headers in DMC
than they are a strict adherence to the C standard. The obvious problem being
that while extensions are fine when implementing someone else's standard, they
set a dangerous precedent when establishing your own--does the presence of
msleep in std.c.time mean that all D implementations need that function there?
I assume since these headers are in std.c it should be apparent that that they
are an implementation of the C spec and any extensions are obviously
non-portable, but a D programmer without a C background may not know which
functions are standard and which are not. The C headers in Ares are a strict
implementation of the C standard (with the exception of alloca and one or two
others--clearly marked by a version(DigitalMars)) and are fairly complete.
They're available here if anyone wants them:
http://svn.dsource.org/projects/ares/trunk/src/ares/std/c/
I've eyeballed the headers in DMC and everything seems to be supported, though
there may be some gaps with GDC.
I'll see about submitting a sleep function for std.thread--the implementations
for Windows and most Unices are quite short.
Sean
we should not do is leave such core functionality as an extension in the
std C library. It should be available (and specified) in the D standard
library. So please go ahead with such std.thread submission :) .
--
Bruno Medeiros - CS/E student
"Certain aspects of D are a pathway to many abilities some consider to
be... unnatural."
↑ ↓ ← → "Regan Heath" <regan netwin.co.nz>
writes:
On Sun, 16 Oct 2005 20:56:30 +0000 (UTC), Hannes
<Hannes_member pathlink.com> wrote:
How do I sleep for a given number of milliseconds?
import std.c.time;
import std.stdio;
//std.c.time contains sleep,msleep,usleep
void main()
{
writefln("Sleep..");
msleep(500);
writefln("Done");
}
sleep - in secs
msleep - in milli secs
usleep - in micro secs
Regan
↑ ↓ ← → Sean Kelly <sean f4.ca>
writes:
In article <opsyrenh1m23k2f5 nrage.netwin.co.nz>, Regan Heath says...
On Sun, 16 Oct 2005 20:56:30 +0000 (UTC), Hannes
<Hannes_member pathlink.com> wrote:
How do I sleep for a given number of milliseconds?
import std.c.time;
import std.stdio;
//std.c.time contains sleep,msleep,usleep
It's worth noting that sleep and usleep are typically found in unistd on Unix
machines, but their presence is optional. I'm not sure why POSIX doesn't define
msleep as well, but it seems a common addition. Sleep( int milliseconds ) is
the corresponding call on Windows systems.
Sean
↑ ↓ ← → "Regan Heath" <regan netwin.co.nz>
writes:
On Mon, 17 Oct 2005 06:46:29 +0000 (UTC), Sean Kelly <sean f4.ca> wrote:
In article <opsyrenh1m23k2f5 nrage.netwin.co.nz>, Regan Heath says...
On Sun, 16 Oct 2005 20:56:30 +0000 (UTC), Hannes
<Hannes_member pathlink.com> wrote:
How do I sleep for a given number of milliseconds?
import std.c.time;
import std.stdio;
//std.c.time contains sleep,msleep,usleep
It's worth noting that sleep and usleep are typically found in unistd on
Unix
machines, but their presence is optional. I'm not sure why POSIX
doesn't define
msleep as well, but it seems a common addition. Sleep( int milliseconds
) is
the corresponding call on Windows systems.
Good point.
I had a feeling msleep wasn't common at all, in fact I was surprised at
it's presence in std.c.time. Another function which is sometimes present
on unix systems is "nanosleep".
Regan
↑ ↓
← → Sean Kelly <sean f4.ca>
writes:
In article <diuepu$2ebg$1 digitaldaemon.com>, Hannes says...
How do I sleep for a given number of milliseconds?
I think that function may be missing from Phobos, though it would be easy to
add. In Ares it's:
Thread.sleep( milliseconds );
Sean
↑ ↓ ← → Niko Korhonen <niktheblak hotmail.com>
writes:
Sean Kelly wrote:
I think that function may be missing from Phobos, though it would be easy to
add. In Ares it's:
Yes, sleep functionality should definitely be in Phobos.
--
Niko Korhonen
SW Developer