class IslandExchangeMailbox extends Object implements Runnable
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
chatty |
static int |
CHECK_TIMEOUT
How much to wait on a socket for a message, before starting to wait on another socket
|
(package private) boolean |
compressedCommunication |
(package private) DataInputStream[] |
dataInput |
Individual[][] |
immigrants
storage for the incoming immigrants: 2 sizes: the subpopulation and the index of the immigrant
|
String[] |
incomingIds |
(package private) Socket[] |
inSockets |
(package private) String |
myId |
(package private) int |
n_incoming |
(package private) int[] |
nextIndexPosition |
int[] |
nImmigrants
the number of immigrants in the storage for each of the subpopulations
|
(package private) boolean[] |
running |
(package private) ServerSocket |
serverSocket |
static int |
SLEEP_BETWEEN_CHECKING_FOR_IMMIGRANTS
How much to wait before starting checking for immigrants
|
(package private) EvolutionState |
state |
static int |
SYNCHRONIZATION_SLEEP
How much to wait while synchronizing
|
(package private) boolean[] |
syncVar |
Constructor and Description |
---|
IslandExchangeMailbox(EvolutionState state_p,
int port,
int n_incoming_p,
int how_many,
String _myId,
boolean chatty,
boolean _compressedCommunication)
Public constructor used to initialize most of the parameters of the mailbox:
state_p : the EvolutionState, used mainly for displaying messages
port : the port used to listen for incoming messages
n_incoming_p : the number of islands that will send messages to the current island
how_many : how many immigrants to manage in the queue-like storage for each of the subpopulations
|
Modifier and Type | Method and Description |
---|---|
int |
getPort()
Return the port of the ServerSocket (where the islands where the other islands should
connect in order to send their immigrants).
|
void |
run()
The main functionality of the mailbox: waiting for incoming messages and dealing with the incoming immigrants
|
void |
shutDown()
Method used to shutdown the mailbox.
|
public static final int SLEEP_BETWEEN_CHECKING_FOR_IMMIGRANTS
public static final int CHECK_TIMEOUT
public static final int SYNCHRONIZATION_SLEEP
public Individual[][] immigrants
public int[] nImmigrants
int[] nextIndexPosition
ServerSocket serverSocket
int n_incoming
boolean compressedCommunication
Socket[] inSockets
DataInputStream[] dataInput
public String[] incomingIds
boolean[] running
EvolutionState state
boolean[] syncVar
String myId
boolean chatty
public IslandExchangeMailbox(EvolutionState state_p, int port, int n_incoming_p, int how_many, String _myId, boolean chatty, boolean _compressedCommunication)
public void run()
public void shutDown()
public int getPort()
Copyright © 2019. All rights reserved.