Thread.sleep (DMD 2.020)

Sean Kelly sean at invisibleduck.org
Sun Nov 2 09:34:55 PST 2008


Steven Schveighoffer wrote:
> "Christopher Wright" wrote
>> John C wrote:
>>> Sean Kelly Wrote:
>>>
>>>> John C wrote:
>>>>> Win32's Sleep(50) seems to be the same as Thread.sleep(500_000). Is 
>>>>> that right?
>>>> Yup.  There should probably be some sort of TimeSpan struct to help 
>>>> prevent these mistakes.
>>>>
>>>>
>>>> Aean
>>> That's why I wrote Mango's TimeSpan way back when...
>> Unfortunately, at the moment, that would mean putting TimeSpan into 
>> druntime (dcore?), which probably isn't going to happen.
>>
>> I hope that TimeSpan can make its way into a core part of Tango 
>> eventually. Socket, for instance, uses struct timeval directly -- if I 
>> recall correctly, client code has to construct timevals, and there's no 
>> constructor provided.
> 
> Tango uses TimeSpan in most places (including Socket) except for core, which 
> can't depend on other libs (TimeSpan resides in tango.time.Time).  In places 
> where TimeSpan cannot be used, or where it was deemed undesirable, a double 
> representing seconds is used.

Walter pointed out to me that by using floating point in a runtime 
module that's always linked (ie. Thread), the floating point support 
code will be linked into every app as well.  This is why I changed the 
sleep routine in druntime.

> My original intention for TimeSpan was for it to be in core for this reason, 
> but I was overruled.  If I had it my way, TimeSpan would be the only 
> representation of time in Tango.

Me too.  It's silly that the core modules use a different representation 
for time than the other modules in Tango simply because the time structs 
were deemed too non-essential to place in the core.


Sean



More information about the Digitalmars-d mailing list