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:

   1. Simple semaphore to synchronize instances of different
      classes (patrick dudjalija)
   2. 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestSynchro.st
Type: application/octet-stream
Size: 2201 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/beginners/attachments/20120814/8d30cdd2/TestSynchro-0001.obj

------------------------------

Message: 2
Date: Tue, 14 Aug 2012 16:07:36 -0400
From: Chris Cunnington <smalltalktelevision@gmail.com>
Subject: Re: [Newbies] Simple semaphore to synchronize instances of
        different       classes
To: beginners@lists.squeakfoundation.org
Message-ID: <502AB008.3030104@gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

On 12-08-14 3:24 PM, patrick dudjalija wrote:
> 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 ad2vance,
>
> 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.
>
>
> _______________________________________________
> Beginners mailing list
> Beginners@lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

http://stephane.ducasse.free.fr/FreeBooks/GuzdialBookDrafts/BuildUI-ch5.pdf

I don't know much about this stuff, but using Semaphore for animations
seems too low level. Pg. 53 of this pdf describes how step and stepTime
work.

HTH,
Chris



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20120814/b2a5039f/attachment-0001.htm

------------------------------

_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 76, Issue 5
****************************************