[gclist] FAQ: distributed objects

Marc Shapiro shapiro@prof.inria.fr
Tue, 19 Mar 1996 14:50:19 +0100


 || Date: Wed, 13 Mar 1996 10:17:04 -0500
 || From: bobduff@world.std.com (Robert A Duff)
 ||
 || I don't understand this paragraph:
 ||
 || > Weighted Reference Count: When an object X is created, it is allocated an
 || > initial weight. The first reference to X carries a weight equal to the
 || > object's. Duplicating any reference to X divides the weight between the
 || > two duplicates. Killing a reference sends a decrement message to the
 || > object's weight. At all times, the sum of the reference weights is equal
 || > to the object's weight.
 ||
 || What do you mean by, "sends a decrement message to the object's weight"?

Let me try an example.  My program creates some object X, storing a pointer to
X in x.  Then it duplicates x a few times (into y, z, t), then it deletes one
of the pointers (say z).

The object has a weight credit WC (initially, say, 32), and each pointer
variable holds an allocated weight AW.  Invariant: the sum of all the AWs for
pointers to X equals the WC of X.

1. Allocate

    x     ------------->  X
     AW=32                 WC=32

2. Duplicate

    x     ---------+--->  X
     AW=16         |       WC=32
                   |
                   |
    y     ---------+
     AW=16

3. Duplicate again

    x     ---------+--->  X
     AW=16         |       WC=32
                   |
                   |
    y     ---------+
     AW=8          |
                   |
                   |
    z     ---------+
     AW=8

3. And again

    x     ---------+--->  X
     AW=16         |       WC=32
                   |
                   |
    y     ---------+
     AW=8          |
                   |
                   |
    z     ---------+
     AW=4          |
                   |
                   |
    t     ---------+
     AW=4

4. Now nil out z; must send a decrement message to X.WC in order to maintain
the invariant

    x     ---------+--->  X
     AW=16         |       WC=(32-4)=28
                   |        ^
                   |        ^
    y     ---------+        ^
     AW=8          |        ^
                   |        ^
                   |        ^
    z >>>>>>>>>>>>>>>>>>>>>>^ decrement by z.AW (=4)
                   |
                   |
                   |
    t     ---------+
     AW=4

This assumes each of the pointer variables lives in a separate process.  I did
not draw the duplication messages flowing between process, but you get the
idea.

                                                Marc