Converting Duration to TickDuration

Jonathan M Davis jmdavisProg at gmx.com
Tue Sep 13 08:39:26 PDT 2011


On Tuesday, September 13, 2011 15:45:27 Vladimir Panteleev wrote:
> On Tue, 13 Sep 2011 06:27:44 +0300, Jonathan M Davis <jmdavisProg at gmx.com>
> 
> wrote:
> > Personally, I'd just Duration far those and not TickDuration. Duration
> > is just
> > as precise (if not more precise) than TickDuration as long as the system
> > ticks
> > aren't less than 1 hnsec apart. TickDuration is useful in that it gives
> > you
> > timing in clock ticks if you need it (e.g. if the system clocks ticks
> > were
> > faster than 1 ever 1 hnsecs), but in the general case, it doesn't buy
> > you
> > anything over Duration, and I don't see why it would in your case
> > either.
> > Maybe something in how you're doing events?
> 
> Well, TickDuration.currSystemTick() returns a TickDuration, so I went with
> that all across. I'll be needing to do some conversions at one point or
> another, though optimally it'd happen when creating events, and not when
> processing them, as that would have less total overhead.

That makes some sense. The cast probably should be added to Duration anyway, 
even if the need is somewhat of an abnormality. And maybe such conversions 
will end up being more common than I would have thought anyway.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list