Discussion:
Event mechanism in tweak
Manuel Wellmann
2006-05-22 21:16:39 UTC
Permalink
Hello,

i have a general question concerning the event mechanism in tweak. When
signaling an event like:

MyClass>>doSomething
...
self signal: #myEventHappened.
...

an handling it in:

MyClass>>onMyEventHappened
<on: myEventHappened>
self halt doSomeThingElse.

the event handler will be executed (and the debugger halts) when sending
"doSomething" within a tweak-workspace. Within a "normal" (squeak)
workspace this does not happen.
Where is this different behavior located exactly? When i debug both
scenarios i can not see the difference.

Best regards,

Manuel Wellmann
Fournier Eric
2006-05-22 21:51:37 UTC
Permalink
Manuel;

When Tweak is started, a completely separate event scheduler is
started that is not running when in Morphic. Generally speaking, you
can (and should) use the Morphic development tools to design Tweak
code, but should run all Tweak code from within the Tweak
environment. Hope this helps.

Eric Fournier
University Technology Development Center
University of Minnesota Office of Information Technology
Post by Manuel Wellmann
Hello,
i have a general question concerning the event mechanism in tweak.
MyClass>>doSomething
...
self signal: #myEventHappened.
...
MyClass>>onMyEventHappened
<on: myEventHappened>
self halt doSomeThingElse.
the event handler will be executed (and the debugger halts) when
sending "doSomething" within a tweak-workspace. Within a
"normal" (squeak) workspace this does not happen.
Where is this different behavior located exactly? When i debug both
scenarios i can not see the difference.
Best regards,
Manuel Wellmann
_______________________________________________
Tweak mailing list
http://impara.de/mailman/listinfo/tweak
Bert Freudenberg
2006-05-23 10:12:28 UTC
Permalink
Eric's explanation is correct.

We need a special scheduler because events are handled
asynchronously. That is, the #signal: send returns immediately, it
only schedules the handler script for execution. Only if the
signalling script ends (or waits voluntarily), another script will be
executed. In this way, Tweak can *guarantee* to not preempt any
script by another one, removing a lot of the headaches normally
associated with multiprocessing.

- Bert -
Post by Fournier Eric
Manuel;
When Tweak is started, a completely separate event scheduler is
started that is not running when in Morphic. Generally speaking,
you can (and should) use the Morphic development tools to design
Tweak code, but should run all Tweak code from within the Tweak
environment. Hope this helps.
Eric Fournier
University Technology Development Center
University of Minnesota Office of Information Technology
Post by Manuel Wellmann
Hello,
i have a general question concerning the event mechanism in tweak.
MyClass>>doSomething
...
self signal: #myEventHappened.
...
MyClass>>onMyEventHappened
<on: myEventHappened>
self halt doSomeThingElse.
the event handler will be executed (and the debugger halts) when
sending "doSomething" within a tweak-workspace. Within a
"normal" (squeak) workspace this does not happen.
Where is this different behavior located exactly? When i debug
both scenarios i can not see the difference.
Best regards,
Manuel Wellmann
m***@public.gmane.org
2006-05-23 10:46:36 UTC
Permalink
Many thanks to both of you.

Could you point at the responsible class(es) for doing the scheduling in the
tweak environment? And: where (in the code) the event is delegated to that
scheduler?

Manuel
Post by Bert Freudenberg
Eric's explanation is correct.
We need a special scheduler because events are handled
asynchronously. That is, the #signal: send returns immediately, it
only schedules the handler script for execution. Only if the
signalling script ends (or waits voluntarily), another script will be
executed. In this way, Tweak can *guarantee* to not preempt any
script by another one, removing a lot of the headaches normally
associated with multiprocessing.
- Bert -
Post by Fournier Eric
Manuel;
When Tweak is started, a completely separate event scheduler is
started that is not running when in Morphic. Generally speaking,
you can (and should) use the Morphic development tools to design
Tweak code, but should run all Tweak code from within the Tweak
environment. Hope this helps.
Eric Fournier
University Technology Development Center
University of Minnesota Office of Information Technology
Post by Manuel Wellmann
Hello,
i have a general question concerning the event mechanism in tweak.
MyClass>>doSomething
...
self signal: #myEventHappened.
...
MyClass>>onMyEventHappened
<on: myEventHappened>
self halt doSomeThingElse.
the event handler will be executed (and the debugger halts) when
sending "doSomething" within a tweak-workspace. Within a
"normal" (squeak) workspace this does not happen.
Where is this different behavior located exactly? When i debug
both scenarios i can not see the difference.
Best regards,
Manuel Wellmann
_______________________________________________
Tweak mailing list
http://impara.de/mailman/listinfo/tweak
Bert Freudenberg
2006-05-23 12:02:55 UTC
Permalink
It's all in the 'Scripting' package - in particular ScriptScheduler,
ScriptProcess, ScriptEvent etc.

The nessage flow from signal to being scheduled is roughly this:

Object>>signal:
Object>>signalEvent:
Object>>privateSignalEvent:
AsyncScriptMessageSend>>valueWithEvent:
ScriptProcess>>newScript
ScriptProcess>>privateRunMsg
ScriptProcess>>startScriptProcess
ScriptScheduler>>scheduleScript:

You'll need a pretty good understanding of Squeak's process handling
to understand what's going on in detail.

- Bert -
Post by m***@public.gmane.org
Many thanks to both of you.
Could you point at the responsible class(es) for doing the
scheduling in the
tweak environment? And: where (in the code) the event is delegated to that
scheduler?
Manuel
Post by Bert Freudenberg
Eric's explanation is correct.
We need a special scheduler because events are handled
asynchronously. That is, the #signal: send returns immediately, it
only schedules the handler script for execution. Only if the
signalling script ends (or waits voluntarily), another script will be
executed. In this way, Tweak can *guarantee* to not preempt any
script by another one, removing a lot of the headaches normally
associated with multiprocessing.
- Bert -
Post by Fournier Eric
Manuel;
When Tweak is started, a completely separate event scheduler is
started that is not running when in Morphic. Generally speaking,
you can (and should) use the Morphic development tools to design
Tweak code, but should run all Tweak code from within the Tweak
environment. Hope this helps.
Eric Fournier
University Technology Development Center
University of Minnesota Office of Information Technology
Post by Manuel Wellmann
Hello,
i have a general question concerning the event mechanism in tweak.
MyClass>>doSomething
...
self signal: #myEventHappened.
...
MyClass>>onMyEventHappened
<on: myEventHappened>
self halt doSomeThingElse.
the event handler will be executed (and the debugger halts) when
sending "doSomething" within a tweak-workspace. Within a
"normal" (squeak) workspace this does not happen.
Where is this different behavior located exactly? When i debug
both scenarios i can not see the difference.
Best regards,
Manuel Wellmann
Loading...