On Wed, Aug 11, 2010 at 1:06 AM, Matt Hammond <[email protected]> wrote:

> >> An unrelated question: What is the best way to set a timer inside of a
> >> component? I am using the threaded Timer, but it is problematic inside
> >> of
> >> the component, it only fires once and cannot be restarted without error.
> >> It
> >> looks like it's underlying thread handling is botching up the top level
> >> thread processing.
>
> > You might want to look at an old code of mine which allowed to reset a
> > timer:
> >
> >
> http://trac.defuze.org/browser/tags/headstock-0.3.3/headstock/lib/monitor.py
> >
> > Still a threaded component mind you.
>
> Gloria, Sylvain: you both got me thinking. Have just committed a little
> experiment:
>
>
> http://code.google.com/p/kamaelia/source/browse/trunk/Sketches/MH/TimerMixIn.py
>
> Would be interested to hear what you think. Feel free to try it out. The
> bottom half of the file is an example usage.
>
>
>
>
I'm usually not a massive fans of mixins as I find they recreate what is the
core nature of Axon: composability. If I was using my threaded monitor
above, I'd have something like:

Pipeline(ThreadedMonitor(), TestComponent(),PassItOn(),ConsoleEchoer()).run()


Where TestComponent wouldn't be a mixing anymore. To me this avoids hiding
the fact the TestComponent is a timer. Instead it states that it requires a
timer which is a different view.


-- 
- Sylvain
http://www.defuze.org
http://twitter.com/lawouach

-- 
You received this message because you are subscribed to the Google Groups 
"kamaelia" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/kamaelia?hl=en.

Reply via email to