[Stackless] Modelling simulated time and granular interruptions

Richard Tew richard.m.tew at gmail.com
Tue Jul 4 14:53:45 CEST 2006


On 7/4/06, stackless at kaishaku.org <stackless at kaishaku.org> wrote:
> > I am writing a non-realtime proof-of-concept simulation.
> >
> > I have Actors. They perform actions which take a specific
> > amount of time. The trouble is, Actors can be interrupted
> > while performing an action and could cancel that action.
>
> This example should show what I'm trying to do.
>
> The thing is, actors will perform as much as they
> can in a specified time (number of ticks). Actions
> will occur across tick boundaries. Actions can be
> cancelled and interrupted, to be resumed later.
>
> My example seems to do what I want, but I find myself
> constantly wondering what task will execute next and
> sometimes what task *should* execute next.

Why?

> I feel this will only get worse and imagine I must
> be misusing stackless. What can I do better here?

Your use of stackless looks fine to me.

I would probably get rid of the whole State concept though
and just send one of three things:

.send(True): Continue with this action.
.send(False): Interrupt the current action.
.send_exception(CancelAction): Cancel the current action,
  catch this in live().  CancelAction is a subclass of
  StandardError I guess.

Richard.

_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless



More information about the Stackless mailing list