Boost logo

Boost :

From: Jesse Jones (jesjones_at_[hidden])
Date: 2001-05-08 21:09:16

At 3:15 PM +0300 5/8/01, Peter Dimov wrote:
>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
> Timer(function<void> const & onTick, int interval);

  I like this better than the cookie approach, but it's still not
quite as clean as my original approach. And, as I mentioned, timers
are the easy case. The harder case is handling menu commands. I don't
want 46 cookies floating around and I don't want 46 helper objects
either. :-)

   -- Jesse

Boost list run by bdawes at, gregod at, cpdaniel at, john at