Re: revised mainEventLoop

Le 8 mar 2013 à 18:57, chris nuernberger a écrit :

> I see what you are saying and you are correct as far as I can tell, this is more efficient.  Don't you need a second while loop for external events that gets called if enabled transitions is empty?

Yes, I was just proposing a modification to the inner loop that handles targetless transitions and internal events and didn't write the context.

> Although depending on your state machine your conditions could check for time differences or some other externally updating information source.  This would mean you would want to poll the eventless transitions again.

Yes, it is possible to raise a hundred thousand useless events and look at the time in a eventless transition's condition, but seriously? for benchmarking that would be irrelevant, and for anything else it is silly. If you need ticks you can instead have a "clock" state generating events at regular intervals with delayed sends and some offset correction, or, for more precision, extend the platform to provide those events.
Internal events should dequeue so fast that you shouldn't expect (and the platform should not push, to prevent race conditions) external modifications to the datamodel during that time. Besides, if your SC is polling external data (rather than listening for mutation events!) with an eventless transition whose repetition depends on stuffing the internal queue with junk events, you deserve to have your code broken in a horrible way :p

			David

Received on Friday, 8 March 2013 18:48:18 UTC