[GemStone-Smalltalk] Transcient instance variable

Paul Baumann via GemStone-Smalltalk gemstone-smalltalk at lists.gemtalksystems.com
Mon Nov 10 09:54:59 PST 2014

Re-send to list...

From: Paul Baumann
Sent: Monday, November 10, 2014 10:47
Subject: RE: [GemStone-Smalltalk] Transcient instance variable

Hi Bob,

"System rcValueCache" is flushed  with a view/transaction change (commitTransaction, abortTransaction, beginTransaction, continueTransaction). Here is an example that shows view-transient behavior:

| anObject get0 get1 |
System beginTransaction.
anObject := Object new.
System rcValueCacheAt: #plbTest put: #remembered for: anObject.
get0 := System rcValueCacheAt: #plbTest for: anObject otherwise: nil.
System commitTransaction.
get1 := System rcValueCacheAt: #plbTest for: anObject otherwise: nil.
Array with: get0 with: get1

anArray( #'remembered', nil)

Your domain object can use itself to retrieve by-reference attributes. A view-transient attribute would be like this:

                ^System rcValueCacheAt: #plbTest for: self otherwise: nil

viewTransient_plbTest: anObject
                System rcValueCacheAt: #plbTest put: anObject for: self

A session-transient attribute would be like this:

                |dict |
                ^(dict := SessionTemps current at: #plbTest otherwise: nil) notNil
                                ifTrue: [dict at: self otherwise: nil].

sessionTransient_plbTest: anObject
                (SessionTemps current at: #plbTest ifAbsentPut: [IdentityDictionary new])
                                at: self put: anObject.

A wrapper object held in an object attribute can be used for better performance when needed. Your domain object would have an attribute that holds information that can find cached data quicker. If the attribute is nil then the no lookup is necessary (saving a search). If the attribute is not nil then it can be something like a reserved index position within a known location (not strongly referenced) that would contain the data. Years ago I had prototyped a cache framework that was able to use a special wrapper for weak references to related objects. It can be done--if you really need that level of performance.

Paul Baumann

From: GemStone-Smalltalk [mailto:gemstone-smalltalk-bounces at lists.gemtalksystems.com] On Behalf Of via GemStone-Smalltalk
Sent: Monday, November 10, 2014 08:25
To: gemstone-smalltalk at lists.gemtalksystems.com
Subject: [GemStone-Smalltalk] Transcient instance variable

I'm considering some refactoring that would benefit from having access to transcient instance variables.
Something like SessionTemps, but stored on an instance variable and cleared on each abort or commit.
It would be used to store pending updates. We do that now with a wrapper object, which works fine,
but the code would be cleaner if the domain object wrapped the pending updates instead.

Anything like that available?

Thanks for any suggestions,
Bob Nemec

This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of Intercontinental Exchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/gemstone-smalltalk/attachments/20141110/6c3a58d9/attachment.html>

More information about the GemStone-Smalltalk mailing list