David Birdsall wrote:
You could implement something yourself, like a collection
of 'Runnable' Tasks in C++ or function pointers in C, and
call them from a nilEvent handler? You'd probably have to
have some code to manage priorities also and you'd have to
make sure your tasks didn't block - perhaps model the tasks
as state machines and have them perform a bit of logic in
each function/method call.

I've thought about doing this for certain tasks, but the chief
problem is that in order to make it work well, everything you do
inside these state machines needs to happen quickly.  If it doesn't,
then you are going to make the app seem really unresponsive to the
user, especially if you have some task that runs often or continuously.

The problem then becomes that you have to make very good estimates
of how long each thing takes.  The problem logic will be broken up
into two layers:  a state machine, and procedural code that runs as
the state machine is making a transition.  If the procedural code
in one step becomes too slow, you have to transform it into part
of your state machine, which basically means rewriting that code.

Not that event-based programming isn't already like that to some
extent, but if you have multiple threads, then the expectation is
that they are CPU-bound or that they tend to wait on things other
than user input.  (Otherwise, why have them?)

  - Logan

--
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to