loggen@cs.eur.nl (R.P. Loggen) (03/26/90)
I have a question about a method in the simulation-classes. In my opinion the method is not very nice. (nice ?) It has to do with the message 'proceed' in the class Simulation. The current version of that method is as follows : Class Simulation : method proceed ---------------------------------------------------------------------- | eventProcess | [self readyToContinue] whileFalse:[Processor yield]. eventQueue isEmpty ifTrue:[^self finishUp] ifFalse:[eventProcess <- eventQueue removeFirst. currentTime <- eventProcess condition. eventProcess resume] ---------------------------------------------------------------------- .....In pseudo code this would be something like : Wait until all simulationProcesses are suspended or terminated. Look if a simulationObject is waiting No : Stop Yes: Activate proces and return from method. In my humble opinion this is not very nice. This method has the side-effect that another process if available is started. Whenever the calling process return's somewhere out there is a little creepy process lingering.... I think a better way is to start up a waiting process and terminate only then when there are no simprocesses running anymore. In that way when starting or leaving the method, the simulation is in a passive state. In pseudo-code: Look if a simulationObject is waiting No : Stop Yes: Activate process Wait until all simulationProcesses are suspended or terminated. (return) In ST : ----------------------------------------------------------------------- | eventProcess | eventQueue isEmpty ifTrue:[^self finishUp] ifFalse:[eventProcess <- eventQueue removeFirst. currentTime <- eventProcess condition. eventProcess resume] [self readyToContinue] whileFalse:[Processor yield]. ----------------------------------------------------------------------- It may be a simple change, but please comment me on this one Regards, Roeland Loggen -- ====================================================================== = Loggen@cs.eur.nl * Roeland Loggen, student Informatics * = = Nothing is an Object, * Erasmus University, the Netherlands * = = even Nothing... =