On 8 October 2012 13:03, Henrik Sperre Johansen <[email protected]> wrote: > On 08.10.2012 11:31, Camillo Bruni wrote: >> >> Just from the deleted wiki page on our google code project site: >> >> >> Squeak startup and shutdown lists are iterated too often, and startup is >> ignored by the network classes. >> >> = Introduction = >> == Squeak/Pharo Problems == >> Squeak's startup and shutdown lists are not used as such. Each snapshot >> forces a shutdown and then a startup. This is not only inefficient, it is >> unfair to things like open sockets, database connections, etc. Platform >> windows will not be well served: imagine shutting down the entire IDE for a >> snapshot; something needs to be done. > > This is false, using startUp:/shutDown: serves exactly this purpose. > >> >> Dolphin does not free external resources on a snapshot. Resources are >> freed on shutdown (by registering for the shutdown events) and >> pointers/handles are cleared on *startup*. Having worked with it for years, >> I have gone from considering it strange to believing it is the correct >> design. >> >> >> == First Steps Toward a Fix == >> It became clear that my life would be easier given a singleton >> SessionManager that triggers #sessionStarted and #sessionStopped. The open >> question was whether Squeak's startup and shutdown lists with the quitting >> and resuming flags would be enough to reproduce Dolphin's behavior, which is >> to trigger #sessionStarted and #sessionStopped when *and only when* the >> image starts and stops, respectively. Somewhat surprisingly, it appears to >> be. I am left wondering why people have tolerated the need to litter images >> with #initializeNetwork sends; that should be done once every time the image >> starts. > > And this is true, you can achieve the same using startUp:/shutDown: as you > can in Dolphin. > Whether that is the best interface, or a manager/announcer would be better > is a different question. > > Ironically, the session object Igor describes would necessitate the same > kind of intrusive checks as #initializeNetwork. >
Then you should do things once at startup. > IMO, lazily checking whether the image has been restarted whenever you want > to do something stinks. > Registering to be notified when image starts/stops is a lot better. > I want both. Doing everything at startup time is not necessary , especially when you want faster startup time. And regarding stinks.. how do you think, a following pseudo-code is less stinky: startup MyClassOne allInstancesDo: [:i | i resetExternalHandle ]. MyOtherClass allInstancesDo: [:i | i clearExternalHandle ]. .... YetAnOtherClass allInstancesDo: [:i | i reinitExternalHandles ]. (a tip: allInstances scanning whole heap) > Cheers, > Henry -- Best regards, Igor Stasenko.
