pydistsim.algorithm.node_wrapper.DMANodeAccess
- class DMANodeAccess(node: Node, manager: WrapperManager, **configs)[source]
Bases:
NodeAccessDMANodeAccess class provides a wrapper for node access with direct memory access. This means that the node’s memory can be accessed directly without the need to use the memory attribute.
For example, instead of using node.memory[“key”], you can use node.key. This works for both setting and getting.
The simplest way to use this class is as follows:
class MyAlgorithm(NodeAlgorithm): class Status(StatusValues): ... def _create_wrapper_manager(self): return self.NODE_WRAPPER_MANAGER_TYPE(self.network, DMANodeAccess)
For a more complex example, see the Mega-Merger algorithm implemented at
pydistsim.demo_algorithms.santoro2007.mega_merger.algorithm.Methods
__init__in_neighborsGet the in-neighbors of the node.
neighborsGet the out-neighbors of the node.
out_neighborsGet the out-neighbors of the node.
unboxAttributes
accessible_getAttributes that can be 'read' from the node base object.
accessible_setAttributes that can be 'read' or 'written' to the node base object.
clockGet the id of the node.
memorystatus- property id
Get the id of the node. If the node does not have an id in memory, a random id will be generated. It is not guaranteed that the id will be unique among all nodes in the network.
Since the id is a read-only attribute, it is cached to avoid generating a new id every time it is accessed.