[COTDC] 18 - SMxMorphicAlarm

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[COTDC] 18 - SMxMorphicAlarm

laurent laffont
Today:  SMxMorphicAlarm


Comment Of The Day Contest - One Day One Comment
Rules: 
#1: Each day a not commented class is elected. Each day the best comment will be integrated with name of the author(s).
#2: If you cannot comment it, deprecate it.
Laurent

Reply | Threaded
Open this post in threaded view
|

Re: [COTDC] 18 - SMxMorphicAlarm

Noury Bouraqadi-2
I'm the exact duplicate of MorphicAlarm in the Simple Morphic world.
I represent a special message sent at some time for some morphic purpose as managed by the morphic world state.

Noury

On 23 févr. 2011, at 20:07, laurent laffont wrote:

> Today:  SMxMorphicAlarm
>
>
> Comment Of The Day Contest - One Day One Comment
> Rules:
> #1: Each day a not commented class is elected. Each day the best comment will be integrated with name of the author(s).
> #2: If you cannot comment it, deprecate it.
> Results: http://code.google.com/p/pharo/wiki/CommentOfTheDayContest
>
> Laurent
>

Noury Bouraqadi
http://car.mines-douai.fr/noury
--
-6th National Conference on
“Control Architecture of Robots”
24-25 may 2011, Grenoble area, France
http://car2011.inrialpes.fr/

-19th ESUG International Smalltalk Conference
22-26 August 2011, Edinburgh, UK
http://www.esug.org/Conferences/2011






Reply | Threaded
Open this post in threaded view
|

Re: [COTDC] 18 - SMxMorphicAlarm

laurent laffont
Finally a funny class ;)

I rephrase a little:

I represent a message sent to be scheduled by the SMxWorldState. I'm the exact duplicate of MorphicAlarm in the Simple Morphic world (see MorphicAlarm comment).


And in MorphicAlarm:

I represent a message to be scheduled by the WorldState.

For example, you can see me in action with the following example which print 'alarm test' on Transcript one second after evaluating the code:

Transcript open.
MorphicUIManager currentWorld
addAlarm: #show: 
withArguments: #('alarm test') 
for: Transcript 
at: (Time millisecondClockValue + 1000).



I haven't been able to test the previous code in SimpleMorphic, there's a MNU when trying to write in the Workspace.


Laurent



On Wed, Feb 23, 2011 at 9:28 PM, Noury Bouraqadi <[hidden email]> wrote:
I'm the exact duplicate of MorphicAlarm in the Simple Morphic world.
I represent a special message sent at some time for some morphic purpose as managed by the morphic world state.

Noury

On 23 févr. 2011, at 20:07, laurent laffont wrote:

> Today:  SMxMorphicAlarm
>
>
> Comment Of The Day Contest - One Day One Comment
> Rules:
> #1: Each day a not commented class is elected. Each day the best comment will be integrated with name of the author(s).
> #2: If you cannot comment it, deprecate it.
> Results: http://code.google.com/p/pharo/wiki/CommentOfTheDayContest
>
> Laurent
>

Noury Bouraqadi
http://car.mines-douai.fr/noury
--
-6th National Conference on
“Control Architecture of Robots”
24-25 may 2011, Grenoble area, France
http://car2011.inrialpes.fr/

-19th ESUG International Smalltalk Conference
22-26 August 2011, Edinburgh, UK
http://www.esug.org/Conferences/2011







Reply | Threaded
Open this post in threaded view
|

Re: [COTDC] 18 - SMxMorphicAlarm

Henrik Sperre Johansen

On Feb 24, 2011, at 8:49 46PM, laurent laffont wrote:

> Finally a funny class ;)
>
> I rephrase a little:
>
> I represent a message sent to be scheduled by the SMxWorldState. I'm the exact duplicate of MorphicAlarm in the Simple Morphic world (see MorphicAlarm comment).
>
>
> And in MorphicAlarm:
>
> I represent a message to be scheduled by the WorldState.
>
> For example, you can see me in action with the following example which print 'alarm test' on Transcript one second after evaluating the code:
>
> Transcript open.
> MorphicUIManager currentWorld
> addAlarm: #show:
> withArguments: #('alarm test')
> for: Transcript
> at: (Time millisecondClockValue + 1000).
>
>
>
> I haven't been able to test the previous code in SimpleMorphic, there's a MNU when trying to write in the Workspace.
>
>
> Laurent
>

For those wondering "why not just use normal delays and  threading system?", you might want to add:
"Compared to doing:
[(Delay forMilliseconds: 1000) wait. Transcript show: 'alarm test'] forkAt: Processor activeProcess priority +1.

the alarm system has 2 distinctions:
- Runs with the step refresh rate resolution.
- Alarms only run for the active world. (Unless a non-standard scheduler is in use)
- Alarms with the same scheduled time are guaranteed to be executed in the order they were added"

At least that's what I could reckon.

Cheers,
Henry



Reply | Threaded
Open this post in threaded view
|

Re: [COTDC] 18 - SMxMorphicAlarm

laurent laffont

Laurent Laffont - @lolgzs

Pharo Smalltalk Screencasts: http://www.pharocasts.com/
Blog: http://magaloma.blogspot.com/


On Fri, Feb 25, 2011 at 12:08 PM, Henrik Johansen <[hidden email]> wrote:

On Feb 24, 2011, at 8:49 46PM, laurent laffont wrote:

> Finally a funny class ;)
>
> I rephrase a little:
>
> I represent a message sent to be scheduled by the SMxWorldState. I'm the exact duplicate of MorphicAlarm in the Simple Morphic world (see MorphicAlarm comment).
>
>
> And in MorphicAlarm:
>
> I represent a message to be scheduled by the WorldState.
>
> For example, you can see me in action with the following example which print 'alarm test' on Transcript one second after evaluating the code:
>
> Transcript open.
> MorphicUIManager currentWorld
>       addAlarm: #show:
>       withArguments: #('alarm test')
>       for: Transcript
>       at: (Time millisecondClockValue + 1000).
>
>
>
> I haven't been able to test the previous code in SimpleMorphic, there's a MNU when trying to write in the Workspace.
>
>
> Laurent
>

For those wondering "why not just use normal delays and  threading system?", you might want to add:
"Compared to doing:
[(Delay forMilliseconds: 1000) wait. Transcript show: 'alarm test'] forkAt: Processor activeProcess priority +1.

the alarm system has 2 distinctions:
- Runs with the step refresh rate resolution.
- Alarms only run for the active world. (Unless a non-standard scheduler is in use)
- Alarms with the same scheduled time are guaranteed to be executed in the order they were added"

At least that's what I could reckon.


Added, thanks Henrik. It's cool to learn.

Laurent

 

Cheers,
Henry




Reply | Threaded
Open this post in threaded view
|

Re: [COTDC] 18 - SMxMorphicAlarm

Stéphane Ducasse
> Added, thanks Henrik. It's cool to learn

yes!!