def test_actor_collision(self): sys = act.ActorSystem("my_sys") ref1 = sys.actor_of(act.SimpleActor, name='ref1') self.assertRaises(act.ContextException, sys.actor_of, act.SimpleActor, name='ref1')
def test_actor(self): sys = act.ActorSystem("my_sys") ref1 = sys.actor_of(act.SimpleActor, name='ref1') ref2 = sys.actor_of(act.SimpleActor, name='ref2') ref1.tell("msg") ref2.tell("diff msg") sys.context.send(ref1, 'from the outside') sys.shutdown()
def test_ping_pong(self): sys = act.ActorSystem( "my_sys", context=para.ThreadingContext(dispatcher=para.UniqueThreader)) pong = sys.actor_of(util.Pong, name='pong') ping = sys.actor_of(util.Ping, other=pong, name='ping') ping.tell(g.Message.create('ping', None)) time.sleep(3)
def test_pingpong_forever(self): graph = act.ActorSystem( "graph", context=para.ThreadingContext(dispatcher=para.UniqueThreader)) node1 = graph.actor_of(util.PingPonger, name="node1") node2 = graph.actor_of(util.PingPonger, name="node2") edge1 = graph.actor_of(g.Edge, name="n1n2", node1=node1, node2=node2) edge1.tell(g.Message.create('edge_insert', None)) time.sleep(1) node1.tell(g.Message.create('ping_pong', 0)) time.sleep(5)
def test_edge_insert_graph(self): graph = act.ActorSystem("graph") node1 = graph.actor_of(g.BasicNode, name="node1") node2 = graph.actor_of(g.BasicNode, name="node2") node3 = graph.actor_of(g.BasicNode, name="node3") edge1 = graph.actor_of(g.Edge, name="n1n2", node1=node1, node2=node2) edge2 = graph.actor_of(g.Edge, name="n1n3", node1=node1, node2=node3) edge1.tell(g.Message.create('edge_insert', None)) edge2.tell(g.Message.create('edge_insert', None)) node1.tell(g.Message.create('broadcast', 'around the world')) edge2.tell(g.Message.create('edge_remove', None)) node1.tell(g.Message.create('broadcast', 'second time'))
def test_graph_utilities(self): graph = act.ActorSystem("graph") node1 = graph.actor_of(g.BasicNode, name="node1") node2 = graph.actor_of(g.BasicNode, name="node2") node3 = graph.actor_of(g.BasicNode, name="node3") # edge1 = graph.actor_of(g.Edge, name="n1n2", node1=node1, node2=node2) # edge2 = graph.actor_of(g.Edge, name="n1n3", node1=node1, node2=node3) g.Utility.insert_edge(graph, node1, node2, name="n1n2") g.Utility.insert_edge(graph, node1, node3, name="n1n3") node1.tell(g.Message.create('broadcast', 'around the world')) # # node1.tell(g.Message.create('remove_edge', edge2)) # node3.tell(g.Message.create('remove_edge', edge2)) node1.tell(g.Message.create('broadcast', 'second time'))