Hello Chris !
Thank you for the link. Free books of Stephane Ducasse are inderdeed a *MUST*. http://stephane.ducasse.free.fr/FreeBooks.html (BTW, everybody should consider a little donation to support him)
I'm realizing that my question is unclear. Let me have a new try in pseudocode.
The problem : synchronizing an instance of a class gameEngine which starts instances of transition screen / game levels.
Game engine
2012/8/15 beginners-request@lists.squeakfoundation.org
Send Beginners mailing list submissions to beginners@lists.squeakfoundation.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.squeakfoundation.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-request@lists.squeakfoundation.org
You can reach the person managing the list at beginners-owner@lists.squeakfoundation.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..."
Today's Topics:
- Simple semaphore to synchronize instances of different classes (patrick dudjalija)
- Re: Simple semaphore to synchronize instances of different classes (Chris Cunnington)
Message: 1 Date: Tue, 14 Aug 2012 21:24:06 +0200 From: patrick dudjalija patrick.dudjalija@gmail.com Subject: [Newbies] Simple semaphore to synchronize instances of different classes To: beginners beginners@lists.squeakfoundation.org Message-ID: <CAEMqm6GttreSY5i+SA=Hg1= C8sAszQOu63miV_R5cfAW5a77Sw@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1"
Hi everybody !
I'm developing an educative game. I've written a "gameEngine" class which does the logic for the general progression in the game : switching between instances of morph subclasses which implement intro screen / mini-games/levels / end screen etc ...
Now, i need to synchronize the instance of the gameEngine class with the instances of the other classes. Example : once the gameEngine starts the instance of a morph subclass which implements a mini-game, it must sleep until the mini-game is finished, and then wake up and does further required switching (next mini-game or intro screen or end screen ...).
i thought that a "simple" semaphore would quickly give a solution to the problem. But i get a freezed code.
I've modelized/simplified the problem with the following workspace code. See also fileout of Class TestSynchro as attachment. TestSynchro has a step method which prints some lines to Transcript, then calls the method stopStepping and signal to the semaphore. The workspace code does a wait, before printing to Transcript 'Hello World'!
Problem is that the code freezes , on the line code -> sem wait I first thought that the code freezed because in the same process. And added a fork to the block which creates instance of TestSynchro. But it does'nt help ...
Any help will be appreciated ! Thanks by advance,
Patrick Dudjalija
|ts sem|
sem:=Semaphore new.
[ts:= TestSynchro new. ts semaphore:sem. ts openInWorld. ts start.] fork.
sem wait. Transcript cr; show:'Hello world !';cr.