Package org.protelis.vm
Interface NetworkManager
-
- All Known Implementing Classes:
SimpleNetworkManager
public interface NetworkManager
Abstraction of networking used by the virtual machine: at each execution round, the VM needs to be able to access the most recent state received from neighbors and to be able to update the state that it is exporting to neighbors. Note, however, that there is no requirement that state actually be sent or received in each round: it is up to the individual implementation of a NetworkManager to best optimize in order to best trade off between effective state sharing and efficiency.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Map<DeviceUID,java.util.Map<CodePath,java.lang.Object>>
getNeighborState()
Called byProtelisVM
during execution to collect the most recent information available from neighbors.void
shareState(java.util.Map<CodePath,java.lang.Object> toSend)
Called byProtelisVM
during execution to send its current shared state to neighbors.
-
-
-
Method Detail
-
getNeighborState
java.util.Map<DeviceUID,java.util.Map<CodePath,java.lang.Object>> getNeighborState()
Called byProtelisVM
during execution to collect the most recent information available from neighbors. The call is serial within the execution, so this should probably poll state maintained by a separate thread, rather than gathering state during this call.- Returns:
- A map associating each neighbor with its shared state. The object
returned should not be modified, and
ProtelisVM
will not change it either.
-
shareState
void shareState(java.util.Map<CodePath,java.lang.Object> toSend)
Called byProtelisVM
during execution to send its current shared state to neighbors. The call is serial within the execution, so this should probably queue up a message to be sent, rather than actually carrying out a lengthy operations during this call.- Parameters:
toSend
- Shared state to be transmitted to neighbors.
-
-