[squeak-dev] Re: [Pharo-project] [ANN] System Events Monitor

Hernán Morales Durand hernan.morales at gmail.com
Sat Dec 13 17:26:29 UTC 2008


Thanks for the feedback from both lists,
  To test the monitor doIt this trivial example:

| obj1 obj2 |

obj1 := VersionNumber fromString: '30'.
obj2 := VersionNumber fromString: '31'.
obj1 when: #myEvent send: #printString to: obj2.
obj1 triggerEvent: #myEvent.
{ obj1 . obj2 } inspect

and start the event monitor. If you use code like that anytime, the monitor
will show you in real-time the event table state.

Possible uses includes:

- As a tool for learning about weak dictionaries, used currently by the
EventManager. An interesting exercise question with the above code is: when
do you think the (Weak)MessageSend will be garbage collected? (try to answer
first without spying possible answers :)

A) Closing the inspector will do it.
B) No, some GC thing will nil event symbols and then the weak messages will
dissapear.
C) Anything doing #flushEvents.
D) Smalltalk garbageCollect.
E) Manually nil all the event symbols in each object's action map:

EventManager actionMaps associationsDo: [: assoc |
    assoc value associationsDo: [: idAssoc |
        idAssoc key = #getCompletionController
            ifFalse: [ idAssoc key: nil ]
     ] ]

F) A winner combination of the above
G) None of the above.

- As a tool for observe an intensive use of SASE events, as we do in some
complex UI applications using SmallFaces.
- As an example of a simple tool for real-time monitoring. If you want your
own monitor, subclass EventMonitor, re-implement #start something like the
following (an example for some morphic events) :

start
    " Start monitoring events "
    | userText |

    userText := UIManager default request: 'Type a class in the Morph
hierarchy'.
    userText isEmptyOrNil
        ifTrue: [ self morphicClass: PasteUpMorph ]
        ifFalse: [ ( Smalltalk hasClassNamed: userText asSymbol )
                    ifTrue: [ self morphicClass: ( Smalltalk at: userText
asSymbol ) ]
                    ifFalse: [ self error: 'Class not found ' , userText ]
].
    super start.

and #eventsReport according to sample your object graph. In this example:

eventsReport
    " Answer a String with the current status of events in my domain "

    | dict |

    ^ String streamContents: [ : s |
        counter := counter + 1.
            s nextPutAll: '====== Samples : ';
                print: counter; cr.
        self morphicClass allSubInstancesDo: [: morph |
            ( dict := morph valueOfProperty: #actionMap )
                ifNotNil: [
                        s nextPutAll: 'Source : ';
                            print: morph; cr;
                            nextPutAll: ' ActionMap : '; cr.
                        dict associationsDo: [: idAssoc |
                            s nextPutAll: '  Event : ';
                                print:  idAssoc key; cr;
                                nextPutAll: '  Message : ';
                                print: idAssoc value; cr ] ].
                        s cr ]
            ]

Cheers

Hernán

2008/12/13 Stéphane Ducasse <stephane.ducasse at inria.fr>

> sounds interesting.
> What is the key behavior (psy unexpected dependencies?
>
> On Dec 13, 2008, at 6:40 AM, Hernán Morales Durand wrote:
>
> > Bonjour chers amis,
> >   Just to let you know that I uploaded a simple real time events
> > monitor to the SqueakSource repository, it could be useful for those
> > who use the SASE protocol (#when:send:to: , #triggerEvent: and
> > friends).
> > Cheers.
> >
> > Hernán
> >
> > PD: Download from http://www.squeaksource.com/EventsMonitor.html
> > _______________________________________________
> > Pharo-project mailing list
> > Pharo-project at lists.gforge.inria.fr
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project at lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20081213/60288340/attachment.htm


More information about the Squeak-dev mailing list