Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-05-08 07:15:31


From: "Jesse Jones" <jesjones_at_[hidden]>

[...]

> >I'm looking at an interface more like:
> >class ITimer {
> > TimerHandle AddTimer(const function<void>& f, int ms, ...);
> > void RemoveTimer(TimerHandle handle);
> > void SetDelay(TimerHandle handle, int ms);
> >};
>
> Sure, you return a cookie used to identify the timer. But if you make
> the reasonable requirement that you can't install multiple timers
> on one callback you can ditch the cookie. I don't think it buys you
> anything: it's just one more piece of data for users to juggle.

Another approach:

class Timer
{
public:
    Timer(function<void> const & onTick, int interval);
};

--
Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk