swarm-support
[Top][All Lists]
Advanced

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

Re: Counting events


From: Roger Burkhart
Subject: Re: Counting events
Date: Mon, 15 Jul 96 19:30:36 MDT

> Is there an easy way to get the total number of pending
> events in a schedule that is fine grained?

For any schedule you can get the number of clock times at which any events
are scheduled using:

  [schedule getCount]

This relies on the fact that a schedule is a kind of Map collection.
Because some of the time values could have a group of events scheduled at
the same time, however, this is not the same as the total number of events.

> Also, is there a way to actually access them in time order?

Yes, by looping through the members of schedule map. This is also
a way to count up the total number of events if you need this.  You open
a standard collection index and then process the members, also testing for
a concurrent group as a member.  The loop would look something like this:

  eventCount = 0;
  index = [schedule begin: aZone];
  while ( (actionAtTime = [index next] ) {
    timeOfAction = (timeval_t) [index getKey];  // key of member is time value
    if ( [actionAtTime respondsTo: M(begin:)] ) {  // test for concurrent group
      groupIndex = [actionAtTime begin: aZone];
      while ( (actionAtTime = [groupIndex next]) ) {
        printf( "at time: %u  action is: "%0#8x\n", actionAtTime );
        eventCount++;
      }
      [groupIndex drop];
    } else {
      printf( "at time: %u  action is: "%0#8x\n", actionAtTime );
      eventCount++;
    }
  }
  [index drop];

The whole area of examining what's in a complex schedule is one in which
we really need some good standardized tools available to help in Swarm
development.  Some sort of standard schedule printing capability, at a
minimum; even better would be an interactive browser of some kind on the
schedule (all the information should be there to do it).  For now you're
unfortunately still on your own to build your own tools.  That's what I'd
recommend for examining what's in the coarse and fine grained schedules in
the code fragements you sent me recently.  It's good to hear, though, that
the addLast: problem went away when adding just at the subschedule level.
That's what should have happened, but your different behavior depending on
what objects you're sending to doesn't seem to make any sense at all.
Instead of a generic print message on each scheduled event as in the above
code, you may want to print out more information about the action, such
as its object class or internal values (access messages for actions are
defined in activity.h and its reference documentation).

Roger


reply via email to

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