On Wed, 15 Aug 2012, patrick dudjalija wrote:

Sorry, i've sent an unfinished mail  ...
Second try :

The problem : synchronizing an instance of a class gameEngine which starts 
instances of classes which implement transition screen / game levels.
Pseudo-level code : 

Game engine
- start introscreen- wait semaphore
-start level 1
- wait semaphore
- start level 2
-wait semaphore
- start finished screen 

See example of code in Squeak with semaphore in my previous mails.
I wonder why the code is freezing.

If you evaluate something in a workspace, it will be executed by the UI process. If you wait for something, then the whole UI will stop responding while you're waiting. Btw, I don't think Semaphores are the thing you're looking for. Semaphores are for synchronizing processes, but AFAIK Morphic is a single process framework.


Levente


Thanks for any help.

Patrick Dudjalija



2012/8/15 patrick dudjalija <[email protected]>
      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 <[email protected]>
      Send Beginners mailing list submissions to
              [email protected]

      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
              [email protected]

      You can reach the person managing the list at
              [email protected]

      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 <[email protected]>
      Subject: [Newbies] Simple semaphore to synchronize instances of
              different       classes
      To: beginners <[email protected]>
      Message-ID:
              
<CAEMqm6GttreSY5i+SA=Hg1=c8saszqou63miv_r5cfaw5a7...@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 <[email protected]>
Subject: Re: [Newbies] Simple semaphore to synchronize instances of
        different       classes
To: [email protected]
Message-ID: <[email protected]>
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
> [email protected]
> 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
[email protected]
http://lists.squeakfoundation.org/mailman/listinfo/beginners


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




_______________________________________________
Beginners mailing list
[email protected]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to