[ENH][VM] Interpreter>>getThisSession

David T. Lewis lewis at mail.msen.com
Sat Nov 17 02:30:01 UTC 2001


Adds a #getThisSession method to the Interpreter, and makes it
accessible to the interpreter proxy for plugins. Increments the
VM_PROXY_MINOR version number to 5. Modifies FilePlugin and its
support code to use the new mechanism.

The session identifier is a 32 bit integer which is used in
SQFile data structures. It is also a field in the SQSocket data
structure, although this is currently unused (at least in the
unix implementation of the socket code). The session identifier
is also potentially useful for identifying distributed squeak
images, and for handling any external resource whose Squeak
representation may become invalid after restarting the image.

This change set moves the session identifier code from the
FilePlugin support code into the Interpreter, and makes it
available to any plugin by means of the interpreter proxy.
Any plugin which needs to obtain the session identifier may
now do so with 'intepreterProxy getThisSession' (in Smalltalk)
or 'interpreterProxy->getThisSession()' (in a hand-coded C plugin
or support code).

The function which initializes the session identifier is defined
as a macro in sq.h, so that it can be easily replaced by a
function in support code if it needs to be improved.

There are several other way to implement this, and I think this
one is the best way to do it. The implementions which I tried are:

1) The current Squeak implemention. A global thisSession variable
is declared in the FilePlugin support code, and managed there. Other
plugins can use the global, but this requires that FilePlugin be
built internally. This works, but it is rather kludgy.

2) Same as #1, but add a #getThisSession method in FilePlugin, and
export it for use by other plugins. Other plugins can use the dynamic
loading mechanism to load the getThisSession function, regardless of
whether the FilePlugin was built internally or externally. This works
fine, but all that dynamic module loading seems a bit over the top
for something this simple.

3) Same as #1, but move the declaration of the global thisSession
variable into the interpreter (as an instance variable in class
Interpreter). This is simple and it works fine. However, having gone
this far, but it would be better to have an accessor method like
in option #2, which leads to the last thing I tried:

4) Replace the global variable with an accessor method in Interpreter,
and have the plugins use this. This works fine, gets rid of the
global variable entirely, and puts responsibility for managing the
session ID in the Interpreter where it belongs.

I think that #4 is the best overall, so that is what I am posting in
this change set.

- Dave

-------------- next part --------------
A non-text attachment was scrubbed...
Name: InterpreterGetThisSession.2.cs.gz
Type: application/x-gunzip
Size: 12587 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20011116/4136c749/InterpreterGetThisSession.2.cs.bin


More information about the Squeak-dev mailing list