Thread overview
[Buglet] sleep() method is seriously large-grained
May 04, 2004
Kris
May 04, 2004
Stewart Gordon
May 04, 2004
Stewart Gordon
May 04, 2004
Kris
May 06, 2004
Phill
May 07, 2004
Walter
May 07, 2004
Phill
Nov 12, 2005
Sean Kelly
Nov 12, 2005
Sean Kelly
May 04, 2004
the std.c.time.sleep(x) method argument is actually in *seconds*; this is
really not very useful <g>

Can we get it changed to represent ms instead? That is; use SleepEx() rather
than Sleep() on Win32 ...

(I know many of these functions don't guarantee granularity below around 20ms, but that's much better than a granularity of 1000ms :-)

- Kris


May 04, 2004
Kris wrote:

> the std.c.time.sleep(x) method argument is actually in *seconds*; this is
> really not very useful <g>
> 
> Can we get it changed to represent ms instead? That is; use SleepEx() rather
> than Sleep() on Win32 ...
<snip>

Better for backward and forward compatibility would be to keep it representing seconds, and have it take a float rather than an int.

That way:
- there'd be no need to change every existing program so that it doesn't run 1000 times too fast
- when an API function comes along that takes microseconds, it'll fit in neatly with Phobos as it stands.  At that point, the millisecond'll be a rather arbitrary choice of unit.  The second, OTOH, is the basic SI unit of time, as well as being a unit in which most people are likely to think, and so remains a reasonable choice.

Stewart.

-- 
My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment.  Please keep replies on the 'group where everyone may benefit.
May 04, 2004
Stewart Gordon wrote:

> Kris wrote:
> 
>> the std.c.time.sleep(x) method argument is actually in *seconds*; this is
>> really not very useful <g>
<snip>

Oops, I overlooked a rather basic aspect!

It is in std.c.  This means that it is an interface to the C RTL.  So unless the RTL changes, std.c.time.sleep isn't going to change.

Still, we can always invent a new function with the semantics I've suggested....

Stewart.

-- 
My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment.  Please keep replies on the 'group where everyone may benefit.
May 04, 2004
Wait! I take it all back. If I'd bothered to read a bit further I'd have
seen the unix-style msleep() and usleep().

Sorry :-(


I marked it as a buglet since I imagine it was actually *meant* to be ms ... I've never seen a runtime library sleep() function that doesn't get any finer than 1000ms intervals. It's almost worthless as it is <g>  Naturally, there's a first time for everything.

The fact that it's still that way may indicate that no-one has really used it yet? It's certainly not used in any of the phobos code.

The windows.d has this instead: export void Sleep(DWORD dwMilliseconds);
But that's not portable.

- Kris


"Stewart Gordon" <smjg_1998@yahoo.com> wrote in message news:c78hoc$kmg$1@digitaldaemon.com...
> Kris wrote:
>
> > the std.c.time.sleep(x) method argument is actually in *seconds*; this
is
> > really not very useful <g>
> >
> > Can we get it changed to represent ms instead? That is; use SleepEx()
rather
> > than Sleep() on Win32 ...
> <snip>
>
> Better for backward and forward compatibility would be to keep it representing seconds, and have it take a float rather than an int.
>
> That way:
> - there'd be no need to change every existing program so that it doesn't
> run 1000 times too fast
> - when an API function comes along that takes microseconds, it'll fit in
> neatly with Phobos as it stands.  At that point, the millisecond'll be a
> rather arbitrary choice of unit.  The second, OTOH, is the basic SI unit
> of time, as well as being a unit in which most people are likely to
> think, and so remains a reasonable choice.
>
> Stewart.
>
> --
> My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment.  Please keep replies on the 'group where everyone may benefit.


May 06, 2004
"Kris" <someidiot@earthlink.dot.dot.dot.net> wrote in message news:c78mhk$so4$1@digitaldaemon.com...
> Wait! I take it all back. If I'd bothered to read a bit further I'd have
> seen the unix-style msleep() and usleep().
>
> Sorry :-(
>
>
> I marked it as a buglet since I imagine it was actually *meant* to be ms
...
> I've never seen a runtime library sleep() function that doesn't get any finer than 1000ms intervals. It's almost worthless as it is <g>
Naturally,
> there's a first time for everything.
>
> The fact that it's still that way may indicate that no-one has really used it yet? It's certainly not used in any of the phobos code.
>

Ive used msleep.

I think these functions taken from C arent they?

Phill



May 07, 2004
"Phill" <phill@pacific.net.au> wrote in message news:c7d44c$1kl0$1@digitaldaemon.com...
> Ive used msleep.
>
> I think these functions taken from C arent they?

They're not taken from C, they hook up directly to the C versions in the C runtime library.


May 07, 2004
"Walter" <newshound@digitalmars.com> wrote in message news:c7fb0q$25cg$1@digitaldaemon.com...
>
> "Phill" <phill@pacific.net.au> wrote in message news:c7d44c$1kl0$1@digitaldaemon.com...
> > Ive used msleep.
> >
> > I think these functions taken from C arent they?
>
> They're not taken from C, they hook up directly to the C versions in the C runtime library.
>
Thats what I meant sorry, it was just a poor choice of words on my part :o(



November 12, 2005
Phill wrote:
> 
> Ive used msleep.
> 
> I think these functions taken from C arent they?

They're optional portions of POSIX.


Sean
November 12, 2005
Sean Kelly wrote:
> Phill wrote:
>>
>> Ive used msleep.
>>
>> I think these functions taken from C arent they?
> 
> They're optional portions of POSIX.

Oops... and I thought I was replying to a recent post :-)


Sean