anthill.antsim.impl
Class ResponseMonitor

java.lang.Object
  |
  +--anthill.antsim.impl.ResponseMonitor
All Implemented Interfaces:
Clearable

public class ResponseMonitor
extends java.lang.Object
implements Clearable

Class ResponseMonitor is

Version:
$Revision$
Author:
Alberto Montresor, Hein Meling

Constructor Summary
ResponseMonitor()
          Instantiates a new ResponseMonitor.
 
Method Summary
 void clear()
          Restores the object to its initial state.
 java.util.Set responses(RequestId rid)
          Returns the responses associated with the specified response identifier.
 java.util.Set responses(RequestId rid, float fraction)
          Returns the responses associated with the specified response identifier if the number of responses received so far exceeds limit.
 boolean returnResources(RequestId rid, Resource[] resources, int timeout)
          Upcall method used to notify this listener that the request associated to it has returned the specified set of resources.
 void setStatistics(Stats stats)
           
 void startRequest(RequestId rid)
           
 void tick()
           
 void tick(int v)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResponseMonitor

public ResponseMonitor()
Instantiates a new ResponseMonitor.
Parameters:
stats -  
Method Detail

clear

public void clear()
Restores the object to its initial state. The network is re-initialized as an empty network.
Specified by:
clear in interface Clearable

setStatistics

public void setStatistics(Stats stats)

tick

public void tick()

tick

public void tick(int v)

startRequest

public void startRequest(RequestId rid)

returnResources

public boolean returnResources(RequestId rid,
                               Resource[] resources,
                               int timeout)
Upcall method used to notify this listener that the request associated to it has returned the specified set of resources.
Parameters:
rid - the request identifier for the returned resources.
resources - the resources found.
Returns:
true if the timeout has passed.

responses

public java.util.Set responses(RequestId rid)
Returns the responses associated with the specified response identifier.
Parameters:
rid - the request identifier whose responses to return.
Returns:
the set of responses associated with the specified response identifier.

responses

public java.util.Set responses(RequestId rid,
                               float fraction)
Returns the responses associated with the specified response identifier if the number of responses received so far exceeds limit.
Parameters:
rid - the request identifier whose responses to return.
fraction - the fraction of unique resources that must be satisfied before we return any responses. If the total number of unique responses is below the limit null is returned.
Returns:
the set of responses associated with the specified response identifier. Returns null if not enough resources has been found yet.