示例#1
1
 public void messageReceived(int to, MessageJ m) {
   try {
     if (m.getType() == AgillaTSResMsg.AM_TYPE) {
       log("Got a results message: " + m);
       // results = (AgillaTSResMsgJ)m;
       synchronized (response) {
         response.add(m);
         // if (timer != null) timer.kill();
         response.notifyAll();
       }
     } else if (m.getType() == AgillaTSReqMsg.AM_TYPE) {
       AgillaTSReqMsgJ reqMsg = (AgillaTSReqMsgJ) m;
       log("Got a request message: " + m);
       processRequest(reqMsg);
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
示例#2
0
 // --------------------------------------------------------------------------
 // BEGIN LOCAL TS OPERATIONS
 public void out(Tuple t) {
   ts.add(t);
   checkRxns(t);
   synchronized (blocked) {
     blocked.notifyAll();
   }
 }
示例#3
0
 /**
  * Registers a reaction on this tuple space.
  *
  * @param rxn The reaction to register
  * @param listener The reaction callback function
  */
 public void registerReaction(Reaction rxn, ReactionListener listener) {
   reactions.add(new RegisteredReaction(rxn, listener));
   for (int i = 0; i < ts.size(); i++) {
     Tuple t = (Tuple) ts.get(i);
     if (rxn.getTemplate().matches(t)) listener.reactionFired(t);
   }
 }
示例#4
0
 public Tuple[] rdgp(Tuple template) {
   Vector matchingTuples = new Vector();
   for (int i = 0; i < ts.size(); i++) {
     Tuple tuple = (Tuple) ts.get(i);
     if (template.matches(tuple)) matchingTuples.add(tuple);
   }
   if (matchingTuples.size() == 0) return null;
   return (Tuple[]) matchingTuples.toArray(new Tuple[0]);
 }