swarm-support
[Top][All Lists]
Advanced

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

Re: rescheduling


From: Ken Cline
Subject: Re: rescheduling
Date: Wed, 21 Apr 1999 18:15:32 -0400 (EDT)

On Wed, 21 Apr 1999, Marcus G. Daniels wrote:

> 2) Conservative use of remove: in notifyFunction
>    
> static void
> notifyFunction (id obj, id unused, void *arg)
> {
>   id controller = (id) arg;
>   id <Schedule> schedule = [controller getSchedule];
>   id action;
>   
>   do {
>     id <MapIndex> index = [schedule begin: scratchZone];
> 
>     while ((action = [index next]))
>       {
>         if ((timeval_t) [index getKey] > getCurrentTime ())
>           {
>             if ([action respondsTo: M(getTarget)])
>               if (obj == [action getTarget])
>                 {
>                   printf (">Removal of address@hidden (target=%s)\n",
>                           (timeval_t) [index getKey],
>                           [[action getTarget] name]);
>                   [schedule remove: action];
>                   break;
>                 }
>           }
>       }
>     [index drop];
>   } while (action);
> }

Thanks for the sample code, Marcus, it'll be very useful!
Possibly this code can be re-packaged into general utility
methods like:

   [ ActivityToolkit remove: Future actionsOn: schedule
                        for: target                     ];

where `Future' is Symbolic short-hand for specifying the use
of the `time > getCurrentTime()' filtering function.  Other
related functions could be: `get:actionsOn:For:' and
`retarget:actionOn:For:To:' and etc.  What do you think?
(I suppose these would be just wrappers for basic methods in
a "CollectionsToolkit", eh? =:-)

Now for some questions about the implementation (please
excuse my ignorance, I'm a little rusty with the Swarm)...

>  if ([action respondsTo: M(getTarget)])

Does this `respondsTo' test work for all actions scheduled
for a particular target object?  What if the actions were
put into an ActionGroup and then the entire ActionGroup was
scheduled?  Is this what you meant by a "Conservative use of
remove:"?

BTW, do ActionGroups stay "grouped" after they are 
scheduled?  I always assumed that they did.

>  [schedule remove: action];

Does the `remove:' message to a Schedule drop the action?
How about its associated key (i.e. timeval_t); does that
memory need to be freed as well?  Is it safe to just drop
and action (and its key); are we sure its not on multiple
schedules?

Finally, why did you use nested loops instead of just
traversing the schedule once?  Is this because you used the
schedule instead of the index to remove the action (i.e.  
the index is no longer pointing at a valid member of the
schedule)?

Thanks in advance.

Ken.

_________________________________________________________
Ken Cline                             address@hidden
SAIC                                 VOICE (410) 571-0413
Annapolis, MD                          FAX (301) 261-8427




                  ==================================
   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]