digitalmars.D - How do I sleep in D?
- Hannes (1/1) Oct 16 2005 How do I sleep for a given number of milliseconds?
- Walter Bright (3/4) Oct 16 2005 std.c.time.msleep()
- Bruno Medeiros (7/16) Oct 17 2005 Now that's pretty strange. Should std.c.time contain sleep, msleep,
- Sean Kelly (19/29) Oct 17 2005 I think the C headers in Phobos are more representative of the C headers...
- Bruno Medeiros (9/51) Oct 22 2005 An extension, I see. I don't mind the existence of extensions, but what
- Regan Heath (15/16) Oct 16 2005 import std.c.time;
- Sean Kelly (6/12) Oct 16 2005 It's worth noting that sleep and usleep are typically found in unistd on...
- Regan Heath (6/23) Oct 17 2005 Good point.
- Sean Kelly (5/6) Oct 16 2005 I think that function may be missing from Phobos, though it would be eas...
- Niko Korhonen (5/7) Oct 17 2005 Yes, sleep functionality should definitely be in Phobos.
How do I sleep for a given number of milliseconds?
Oct 16 2005
"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()
Oct 16 2005
Walter Bright wrote:"Hannes" <Hannes_member pathlink.com> wrote in message news:diuepu$2ebg$1 digitaldaemon.com...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 ? -- Bruno Medeiros - CS/E student "Certain aspects of D are a pathway to many abilities some consider to be... unnatural."How do I sleep for a given number of milliseconds?std.c.time.msleep()
Oct 17 2005
In article <dj0022$30lh$1 digitaldaemon.com>, Bruno Medeiros says...Walter Bright wrote: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"Hannes" <Hannes_member pathlink.com> wrote in message news:diuepu$2ebg$1 digitaldaemon.com...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 ?How do I sleep for a given number of milliseconds?std.c.time.msleep()
Oct 17 2005
Sean Kelly wrote:In article <dj0022$30lh$1 digitaldaemon.com>, Bruno Medeiros says...An extension, I see. I don't mind the existence of extensions, but what 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."Walter Bright wrote: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"Hannes" <Hannes_member pathlink.com> wrote in message news:diuepu$2ebg$1 digitaldaemon.com...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 ?How do I sleep for a given number of milliseconds?std.c.time.msleep()
Oct 22 2005
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
Oct 16 2005
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: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. SeanHow do I sleep for a given number of milliseconds?import std.c.time; import std.stdio; //std.c.time contains sleep,msleep,usleep
Oct 16 2005
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...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". ReganOn Sun, 16 Oct 2005 20:56:30 +0000 (UTC), Hannes <Hannes_member pathlink.com> wrote: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.How do I sleep for a given number of milliseconds?import std.c.time; import std.stdio; //std.c.time contains sleep,msleep,usleep
Oct 17 2005
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
Oct 16 2005
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
Oct 17 2005