Resolution of core.time.Duration...

Alexander aldem+dmars at nk7.net
Tue May 17 03:15:54 PDT 2011


...why it is in hnsec? I know that this resolution is used in Win32 API (file time), but since TickDuration may be 1 ns resolution, wouldn't it be better to make Duration to be stored with maximum (defined so far) resolution?

Especially because Duration may not hold long intervals (> months) - so there is no problem with overflow.

Thread.sleep() accepts Duration (or hnsec) as an argument, while system resolution is higher, and on some systems it is even possible that it can sleep less than 100ns.

SysTime is also kept in hnsecs, while resolution of system time (on Linux at least) is 1ns. Sure, in case of SysTime it is all bound to overflow, but it depends how value is stored - if we split seconds and nanoseconds, it will be fine.

Additionally, when accepting long values as an argument for duration it is more logically to use SI units :)

/Alexander


More information about the Digitalmars-d mailing list