I like your idea, but just so this does not get overlooked:

See also [Stack]Interpreter>>getThisSessionID which is used in e.g.
OSProcessPlugin>>primitiveGetSession for external resource management.
You could move the primitive into the interpreter if you wanted to make
it mandatory.

This is the same session identifier that is used in the file and socket
plugins, so it might have some advantages over using a newly allocated
object that would not get allocated until after the plugins are already
initialized. But it does need VM support, so your Object new approach is
better in that respect.

Dave

On Mon, Oct 08, 2012 at 05:11:34AM +0200, Igor Stasenko wrote:
> I wanna have this:
> 
> SmalltalkImage>>snapshot: save andQuit: quit
> ...
> resuming ifTrue: [ session := self newSession ].
> ...
> 
> (where session is additional instance variable of SmalltalkImage).
> 
> SmalltalkImage>>newSession
> "Just answer unique object, which never can be identical to any
> previous session object,
> this is all what we need for detecting session change.
> A session object don't needs to carry any state (we have plenty of
> other objects in image which can do this for us). it just needs to be
> unique"
> 
>   ^ Object new.
> 
> SmalltalkImage>>session
>  ^ session
> 
> then, i can write in own code:
> 
> Smalltalk session == mySession ifFalse: [  self initForNewSession.
> mySession := Smalltalk session ]
> 
> So, basically, this little addition allows you to detect whether
> session changed or not between
> two different calls to your code (given that you remembered the
> previous session somewhere).
> Currently we don't have such feature, and looking how some existing
> code deals with session management,
> i see how it can be simplified.
> If you want to do something similar today, you will need to register
> in startup list.. which IMO stinks ;)
> 
> i don't like using startup lists, since you never know , what is the
> right order of resource initialization,
> and what inter-dependencies they may form, and changing dependencies
> over time will require changing startup order, again and again. Not
> fun.
> This technique allows you to lazily re-initialize any of your
> object(s) due to session change, once the control flow hits your code,
> but not before.
> (so you don't have to do all accounting at image startup time, you
> doing it only when it required/requested, which means shorter image
> startup time).
> 
> The notion of session is highly important for external resource management.
> 
> I using it in NativeBoost from very beginning, and wanna propose to
> use it globally.
> 
> 
> -- 
> Best regards,
> Igor Stasenko.

Reply via email to