Package datk :: Package core :: Module distalgs :: Class Process
[hide private]
[frames] | no frames]

Class Process

source code

A computing element located at a node of a network graph. Processes are identical except for their UID

Instance Methods [hide private]
 
__init__(self, UID, state=None, in_nbrs=[], out_nbrs=[]) source code
 
link_to(self, new_out_nbr)
Adds a new outgoing neighbor of the Process
source code
 
bi_link(self, nbr)
Adds a new out_nbr of the Process, and adds the Process as an out_nbr of that neighbor
source code
 
output(self, key, val, verbose=True)
Sets the publicly visible value of self.state[key] to val
source code
 
send_to_all_neighbors(self, msg)
Sends a message to all out_nbrs
source code
 
send_msg(self, msg, out_nbrs=None)
Sends a Message from Process to some subset of out_nbrs
source code
 
get_msgs(self, algorithm, in_nbrs=None)
Removes all Messages that relate to a particular Algorithm from the Process' incoming channels (or from some subset of incoming channels).
source code
 
add(self, algorithm)
Causes the Process to wake up with respect to algorithm
source code
 
terminate(self, algorithm)
Causes the Process to halt execution of algorithm
source code
 
__str__(self) source code
 
__repr__(self) source code
Method Details [hide private]

output(self, key, val, verbose=True)

source code 

Sets the publicly visible value of self.state[key] to val

Parameters:
  • key - The state variable to set
  • val - The value to assign to it
  • verbose - Dictates whether or not to print this event to STDOUT

send_to_all_neighbors(self, msg)

source code 

Sends a message to all out_nbrs

Parameters:
  • msg - the message to send

send_msg(self, msg, out_nbrs=None)

source code 

Sends a Message from Process to some subset of out_nbrs

Parameters:
  • msg - The message to send.
  • out_nbrs - The out_nbrs to send the message to. This may be a subset of the Process's out_nbrs, or None, in which case the message will be sent to all out_nbrs

    Effects:

    • Sets msg.author = self

get_msgs(self, algorithm, in_nbrs=None)

source code 

Removes all Messages that relate to a particular Algorithm from the Process' incoming channels (or from some subset of incoming channels). Returns them.

Parameters:
  • algorithm - the algorithm whose messages this returns
  • in_nbrs - the in_nbrs of the Process from whose channels we are getting messages. If None, fetches messages from all channels
Returns:
A list of Messages, msgs, such that every message in msgs has Algorithm algorithm, and author in in_nbrs