pydistsim.algorithm.node_wrapper.DMANodeAccess

class DMANodeAccess(node: Node, manager: WrapperManager, **configs)[source]

Bases: NodeAccess

DMANodeAccess 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_neighbors

Get the in-neighbors of the node.

neighbors

Get the out-neighbors of the node.

out_neighbors

Get the out-neighbors of the node.

unbox

Attributes

accessible_get

Attributes that can be 'read' from the node base object.

accessible_set

Attributes that can be 'read' or 'written' to the node base object.

clock

id

Get the id of the node.

memory

status

__setattr__(name: str, value: Any) None[source]

Implement setattr(self, name, value).

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.