swarm-support
[Top][All Lists]
Advanced

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

Two actions at one time in schedule breaks next


From: Tee Toth-Fejel
Subject: Two actions at one time in schedule breaks next
Date: Wed, 15 Nov 2000 18:12:30 -0500

> -----Original Message-----
> From: address@hidden [mailto:address@hidden
> Sent: Wednesday, November 15, 2000 5:10 PM
> To: address@hidden
> Subject: Re: FArgumentsImpl broken in swarm.jar; jheatbugs 
> can't compile
> 
> 
> >>>>> "TTF" == Tee Toth-Fejel <address@hidden> writes:
> 
> TTF> nor have I figured out yet how to change the source code that the
> TTF> Schedule.describeForEach depends on so that I can handle two
> TTF> actions at the same time unit.  Because that is what I *really*
> TTF> want to do.
> 
> Why?

Because for a distributed application, I need to be able to access and
control the schedule.

Specifically, I need to be able to:

Examine an action that occurs "simulaneously" with the rest of the actions
at that time, and make sure it happens last (i.e. a clean up and done
action)

Given any particular time, I need to be able to examine the schedule and
return the time of the next event in the schedule. 

The problem is that when more than one actions is scheduled at one time
slot, shedule.next breaks.  Here is the code:


import swarm.activity.ScheduleImpl;
import swarm.simtoolsgui.GUISwarmImpl;
import swarm.activity.Schedule;
import swarm.objectbase.SwarmImpl;
import swarm.defobj.Zone;
import swarm.collections.Index;
import swarm.Selector;
import swarm.Globals;

public class TestMapIndexOld extends SwarmImpl {

  public static void main (String[] args)
    {
    System.out.println ("main: starting initSwarm");
    Globals.env.initSwarm("TestMapIndexOld", "0.0", "address@hidden",
args);
    System.out.println ("main: finished initSwarm, creating
TestMapIndexOld");
    try
      {
      TestMapIndexOld obj = new TestMapIndexOld (Globals.env.globalZone);
      System.out.println("main: finished TestMapIndexOld, starting
buildActions");
      obj.buildActions ();
      System.out.println("main: finished buildActions");
      obj.test ();
      }
    catch (NoClassDefFoundError ncdferr)
      {
      System.out.println("main: error "+ncdferr);
      ncdferr.printStackTrace();
      }
  }

  Schedule schedule;

  public TestMapIndexOld (Zone aZone) {
    super (aZone);
    //super ();
    System.out.println("TestMapIndexOld: constructor");
  }

  public void message1 () {
    System.out.println ("message1");
  }

  public void message2 () {
    System.out.println ("message2");
  }

  public void message3 () {
    System.out.println ("message3");
  }

  public Object buildActions () {
    schedule = new ScheduleImpl (Globals.env.globalZone, true);

    try {
      Selector sel1 = new Selector (getClass (), "message1", false);
      Selector sel2 = new Selector (getClass (), "message2", false);
      Selector sel3 = new Selector (getClass (), "message3", false);
      schedule.at$createActionTo$message (1, this, sel1);
      schedule.at$createActionTo$message (2, this, sel2);
      schedule.at$createActionTo$message (2, this, sel3);  
        // change time above to 2 to make it fail; 3 to pass 
    } catch (Exception e) {
      e.printStackTrace (System.err);
      System.exit (1);
    }
    return this;
  }

  public void test () {
    Index index = schedule.begin (getZone ());

    System.out.println ("test: index="+index);
    System.out.println ("test: index.getName="+index.getName ());
    System.out.println ("first event: " + index.next ());
    System.out.println ("second event: " + index.next ());
    System.out.println ("third event: " + index.next ());
  }
}


If I change the scheduled time from 2 to 3 on line 63, it works fine.

Thanks in advance for any help.

Tihamer "Tee" Toth-Fejel                    Member of Technical Staff
(734) 623-2544   address@hidden      http://www.erim.org/ 
Center for Electronic Commerce, Environmental Research Institute of Michigan




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