swarm-support
[Top][All Lists]
Advanced

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

getCurrentTime question


From: Roger M. Burkhart
Subject: getCurrentTime question
Date: Fri, 12 Jul 1996 16:12:39 -0500

> To get the present system time with the fine grained schedule times
> I first get the fractional part of the time (the sub schedule time)
> using getCurrentTime() I then get the integer part of the time
> (the schedule time) using [currentActivity->owner getCurrentTime].
> This call seems to return an incorrect time value if there is more
> than one event scheduled at the identical time in the subschedule.
> In other words, if two events have identical schedule and subschedule
> times and one is the current activity then the using
> 
> [currentActivity->owner getCurrentTime]
> 
> to get the present schedule time doesn't seem to work.
> 
> Is my diagnosis correct and if so is there an easy way to fix this?

Yes, your diagnosis is correct and there is an easy way to fix it.

Your use of the expression currentActivity->owner isn't giving you what
you think.  If you've got more than one event at the same time, the
owner isn't a schedule but a concurrent group created by the schedule
for the group of concurrent actions.  In any event, you shouldn't be
referencing internal instance variables like your currentActivity->owner
(they're always subject to change).  Use the message getOwner to get the
owner activity, not the instance variable.  (Especially when running under
swarms, the instance variable isn't always what you think.)

You basically have to look at the type of owner on the stack to see if
it's a schedule.  Try:

  ownerActivity = [currentActivity getOwner];
  if ( ! [ownerActivity respondsTo: M(getCurrentTime)] )
    ownerActivity = [ownerActivity getOwner];
  currentTime = [ownerActivity getCurrentTime];

We could build this search up the stack into the getCurrentTime message
but it's not there now.

Roger Burkhart




reply via email to

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