swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help on walking lists of Swarm Collection


From: Marcus G. Daniels
Subject: Re: Help on walking lists of Swarm Collection
Date: 11 May 1999 09:31:43 -0700

>>>>> "WS" == William S Shu <address@hidden> writes:

WS> The malariaPopModelSwarm grabs the colonyList and removes the dead
WS> agent, possibly before the person agent has finished with it!  In
WS> computing terms, colonyList becomes a critical resource which must
WS> be accessed only by exactly the one agent modifying it.

It's important to ensure that accesses to colonyList (index creation
and disposal) happen at a different time from changes to colonyList.
If that's not feasible, write a single access method for accessing
colonyList, one that will ensure that broken indices won't ever be
used.  One way to do this is to have a flag that is set by a notify
function that will cause the access method to break out of any index
iteration that is currently underway, recreating the indices.

WS> The notify function is declared as follows.

WS>  void
WS>  notifyFunction (id obj, id unused, void *arg)
WS>   {
WS>    // obj = object notified (receiver of addRef: message)
WS>    // arg = is argument given after withArgument:. can be any pointer thing
WS>    // unused = is currently unused

Yes.

WS> objX sends an addRef: to objY (message receiver) as follows:
WS>     objXVariable = [objY addRef: notifyFunction withArgument: arg];

Yes.

WS> The notifyFunction is called (with objY as 1st arg) when objY is being
WS> dropped via the drop message

Yes.

WS> objX revokes notification by issuing:
WS>    [objX removeRef: objXVariable];

You'd send it to objY. 

WS> Should objX want to remove any pointers (id's) it holds of objY  it builds
WS> notifyFunction as follows (with args corresponding to objX and objY):

WS>    objXVariable = [objY addRef: notifyFunction withArgument: objX];

WS>    void
WS>    notifyFunction (id objY, id unused, void *arg)
WS>    {
WS>      // objY = receiver of addRef: message
WS>      // arg = holds id of objX
WS>      // unused = is currently unused

WS>    objX = (id)arg;            // circumvent [data]-typing constraints

WS>    ... remove occurences of objY from objX ...
WS>
WS>  }

Yes.

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]