Object copying API
Description
The Distributed feature provides several APIs you can use to create local copies of remote objects. By using these methods, you request that an object be passed by value rather than by reference, if it is possible. These methods include--
asDsByValueObject
By sending the message asDsByValueObject to an object, you request that the object be passed by value rather than by reference, if possible. For local objects, which would otherwise pass by reference, the asDsByValueObject method returns a proxy for the receiver. The proxy imitates the receiver object and causes the receiver to be passed by value, when sent to another object space.
asDsByValueArray
This message returns the receiver converted to an Array of class DsByValueArray. A DsByValueArray is always passed by value. The elements of the array are not affected and will be passed by their own default rules. Although the objects in the array might reside in other object spaces, the DsByValueArray itself is always local.
dsPerformWithLocalResult:
This message functions much like the base Smalltalk method perform:, except that the object returned is a local object. If the result of the perform is a remote object, it is copied to the local object space, if it is possible to do so.
SST equivalent
SST provides marshaling wrappers that specify how an object is to be passed to another object space. The following APIs will return a corresponding marshaling wrapper for the receiver object:
sstAsDeepValue
This method answers a deep value marshaling wrapper, on the receiver, containing the receiver and dictating that the receiver should be marshaled by deep copy.
sstAsShallowValue
This method answers a shallow value marshaling wrapper, on the receiver, containing the receiver and dictating that the receiver should be marshaled to one level of value.
sstAsReference
This method will answer a reference marshaling wrapper, on the receiver, containing the receiver and dictating that the receiver should be marshaled with a reference to the local object.
Porting guidelines
The Distributed feature object copying methods can be converted to SST as follows:
asDsByValueObject
Replace the asDsByValueObject method with the SST method sstAsDeepValue.
asDsByValueArray
Replace the asDsByValueArray method with the SST method sstAsShallowValue.
dsPerformWithLocalResult:
There is no equivalent function to dsPerformWithLocalResult:. Users of SST can achieve the same function as the dsPerformWithLocalResult: method by optimizing their application code. In the method executed on the remote object space, the result object can be returned by value, by sending it the sstAsDeepValue method.
In SST, the sstAsDeepValue and sstAsShallowValue methods return a wrapper object that does not imitate the behavior of the receiver. The wrapper should only be used as part of a remote message send. In contrast, for the Distributed feature the asDsByValueObject method returns a proxy object and the asDsByValueArray method returns an object of type Array. These objects will behave like the receiver, prior to their use in a remote message send.
Last modified date: 07/02/2019