swarm-support
[Top][All Lists]
Advanced

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

Re: setDefaultOrder (java)


From: Marcus G. Daniels
Subject: Re: setDefaultOrder (java)
Date: 14 Sep 2001 11:28:39 -0600
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.7

>>>>> "MA" == Myriam Abramson <address@hidden> writes:

MA> How do I exactly specify the argument of setDefaultOrder in Java?
MA> I did setDefaultOrder (new SymbolImpl(getZone(),"Concurrent")) and
MA> that compiled but produced an illegal argument at run time.

Below is an example.  (The predefined symbols live in Globals.env.)

MA> Is this feature simulated on a single processor?

`Concurrent' isn't implemented, only Randomized.  No, don't bother
complaining: implement it or send money... :-)


import swarm.objectbase.SwarmImpl;
import swarm.objectbase.Swarm;
import swarm.activity.Schedule;
import swarm.activity.ScheduleImpl;
import swarm.activity.Activity;
import swarm.defobj.Zone;
import swarm.Selector;

import swarm.Globals;

public class TestRandomize extends SwarmImpl {
    Schedule schedule;

    TestRandomize (Zone aZone) {
        super (aZone);
    }
    
    public void bonk () {
        System.out.println ("bonk @ " + Globals.env.getCurrentTime ());
    }

    public void bap () {
        System.out.println ("bap @ " + Globals.env.getCurrentTime ());
    }

    public Object buildActions () {
        super.buildActions ();

        schedule = new ScheduleImpl (getZone (), false);
        schedule.setDefaultOrder (Globals.env.Randomized);

        try {
            Selector sel1 = new Selector (getClass (), "bonk", false);
            Selector sel2 = new Selector (getClass (), "bap", false);

            schedule.at$createActionTo$message (0, this, sel1);
            schedule.at$createActionTo$message (0, this, sel2);
        } catch (Exception e) {
            e.printStackTrace (System.err);
            System.exit (1);
        }

        return this;
    }

    public Activity activateIn (Swarm swarmContext) {
        super.activateIn (swarmContext);

        schedule.activateIn (this);
        return getActivity ();
    }
        

    static void main (String args[]) {
        Globals.env.initSwarm ("TestRandomize", "0.0", "address@hidden",
                               args);

        TestRandomize testRandomize =
            new TestRandomize (Globals.env.globalZone);

        testRandomize.buildObjects ();
        testRandomize.buildActions ();
        testRandomize.activateIn (null).run ();
    }
}


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