Re: Lahman, how ya doing?



In article <gNtbe.1007$pc7.41@trndny05>,
H. S. Lahman <hsl@xxxxxxxxxxxxxxxxx> wrote:
>Responding to Hansen...
>
>> I'd started with a Timer class that keeps the total time separately in
>> each individual instantiation, but I thought that wasn't quite logically
>> representative since there's only one time. I thought it still wasn't
>> worthwhile changing that until I realized that main() was pretty much
>> doing what I'd have Clock doing anyway.
>
>As you noted, you only need one timer if you have different events for
>different frequencies. The timer just spits out the right event after
>the proper number of internal "ticks". If you use a single FIFO event
>queue, then the ordering of operations will Just Work.
>
>But that leaves the problem of "registering" the right receivers for
>those events so that Timer can address them correctly. Since there is
>nothing dynamic about that assignment, I agree with Martin that it seems
>like something timer.add would do. [If the listener assignments were
>more dynamic in nature a pattern like Observer might be relevant.]

Yes, I'm working on Martin's idea now. What I had was sort of an
evolution of what I'd started with. That doesn't always turn out looking
the cleanest to a third party.

I also need jobs that do task 1 at time interval 1, and task 2 at time
interval 2. But it won't be hard to add a

time.add_task(&c3, 5, 20);

Well, I had a little trouble getting it to work before, I think it must
have had to do with typecasting the pointers. For a container holding a
double event job I wound up rewriting a few member functions in the
derived class identically except for different pointer types. Maybe
there was a better way, but what was rewritten was short enough that there
didn't seem to be any point in getting fancy.

--
"Is that plutonium on your gums?"
"Shut up and kiss me!"
-- Marge and Homer Simpson
.



Relevant Pages

  • POSIX based Timer class, occasional crash
    ... I've got a Timer class and a TimerClient base class. ... number of times to fire the timer, timer attributes, a pointer to the ... client, and a pointer to a client specific "payload" that gets ...
    (comp.unix.programmer)
  • Re: Timers
    ... so do i set the interval to x amount of milliseconds based on milliseconds ... It seems to me your best bet is to determine the exact time in the future you want the timer to execute, calculate the difference between that exact time and "now", and then use the result of that as the timer delay for a one-shot timer. ... It will fire when the elapsed time has expired. ... Each timer class has a slightly different syntax for configuring it as a one-shot timer, so without knowing what class you're using, it's not possible to say for sure what you would want to do. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: when is threading better than a timer?
    ... Looks like I was using the right Timer class, ... Bob ...
    (microsoft.public.dotnet.languages.vb)
  • Re: thread differences from button_Click and timer_Elapsed
    ... it would be the timer that uses a different thread (it ... but rather get one from the thread pool). ... does that depends on which timer class you're using. ... compare them between the two executions ...
    (microsoft.public.dotnet.framework)
  • Re: POSIX based Timer class, occasional crash
    ... > I've got a Timer class and a TimerClient base class. ... > Every once in a while an application that is using the timer crashes, ...
    (comp.unix.programmer)