Changeset 20 for branches/multithread

Show
Ignore:
Timestamp:
09/24/07 14:06:42 (1 year ago)
Author:
max
Message:
 
Location:
branches/multithread/src/planet
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/multithread/src/planet/generic/commonapi/MultiThreadedNetworkImpl.java

    r14 r20  
    8484     */ 
    8585    public MultiThreadedNetworkImpl() { 
    86         PROCESSORS = 2; 
     86        PROCESSORS = Properties.simulatorProcessors; 
    8787        nodes = new HashMap<NodeHandle, Node>();    //to contain all nodes 
    8888        toRemove = new Stack<NodeHandle>(); 
  • branches/multithread/src/planet/util/Properties.java

    r2 r20  
    144144     */ 
    145145    public static final String SIMULATOR_PROCESSED_MESSAGES                     = "SIMULATOR_PROCESSED_MESSAGES"; 
     146    /** 
     147     * Simulator property: Default key specified in the properties file that 
     148     * identifies the number of processors the simulator runs on. 
     149     */ 
     150    public static final String SIMULATOR_PROCESSORS                                                     ="SIMULATOR_PROCESSORS"; 
    146151 
    147152    /* OPTIONAL */ 
     153     
    148154    /** 
    149155     * Simulator property: Default key specified in the properties file that 
     
    405411    public static int simulatorProcessedMessages                                = 0; 
    406412 
     413    /** 
     414     * Simulator property: Number of processor for the simulator. 
     415     */ 
     416    public static int simulatorProcessors = 1; 
    407417    /* OPTIONAL */ 
     418     
     419     
    408420    /** 
    409421     * Simulator property: The events filename to be loaded. 
     
    830842        Properties.simulatorQueueSize         = properties.getPropertyAsInt(SIMULATOR_QUEUE_SIZE); 
    831843        Properties.simulatorProcessedMessages = properties.getPropertyAsInt(SIMULATOR_PROCESSED_MESSAGES); 
    832          
     844        Properties.simulatorProcessors = properties.getPropertyAsInt(SIMULATOR_PROCESSORS); 
    833845        //testing the correctness of the values 
     846        ensureValidNumberOfProcessors(Properties.simulatorProcessors); 
    834847        ensureValidSimulatorEnvironment(Properties.simulatorEnvironment); 
    835848        ensureValidPrintLevel(Properties.simulatorPrintLevel); 
    836849    } 
    837      
    838     /** 
     850    /** 
     851     * Test if the <b>number of processor</b> is a valid. 
     852     * @param simProcessors The value to be tested. 
     853     * @throws InitializationException if the <b>simProcessors</b> has an  
     854     * incorrect value. 
     855     */ 
     856    private static void ensureValidNumberOfProcessors(int simProcessors) throws InitializationException{ 
     857                if(simProcessors<1){ 
     858                        throw new InitializationException(simProcessors+" is not a valid number for "+SIMULATOR_PROCESSORS+" must be >=1"); 
     859                } 
     860                 
     861        } 
     862 
     863        /** 
    839864     * Test if the <b>environment</b> is a valid simulator environment. 
    840865     * @param environment The value to be tested.