/** * package constructor: called by OtpNode:createMbox(name) to create a named mbox */ internal OtpMbox(OtpNode home, OtpErlangPid self, string name) { Name = name; Self = self; this.home = home; links = new Links(10); }
public Mailboxes(OtpNode node, OtpActorSched sched) { this.node = node; this.sched = sched; byPid = new Dictionary <OtpErlangPid, WeakReference>(); byName = new Dictionary <String, WeakReference>(); }
/* * Intiate and open a connection to a remote node. * * @exception java.io.IOException if it was not possible to connect to the * peer. * * @exception OtpAuthException if handshake resulted in an authentication * error. */ // package scope internal OtpCookedConnection(OtpNode self, OtpPeer other) : base(self, other) { this.self = self; links = new Links(25); start(); }
/* * Accept an incoming connection from a remote node. Used by {@link * OtpSelf#accept() OtpSelf.accept()} to create a connection based on data * received when handshaking with the peer node, when the remote node is the * connection intitiator. * * @exception java.io.IOException if it was not possible to connect to the * peer. * * @exception OtpAuthException if handshake resulted in an authentication * error */ // package scope internal OtpCookedConnection(OtpNode self, BufferedTcpClient s) : base(self, s) { this.self = self; links = new Links(25); start(); }
// package constructor: called by OtpNode:createMbox(name) // to create a named mbox internal OtpMbox(OtpNode home, OtpErlangPid self, String name) { this.self = self; this.home = home; this.name = name; queue = new GenericQueue(); links = new Links(10); }
public static void Main(string[] args) { OtpNode pingNode = new OtpNode("ping"); OtpNode pongNode = new OtpNode("pong"); bool ok = pingNode.ping("pong", 10000); pingNode.close(); pongNode.close(); Environment.Exit(ok ? 0 : 1); }
public Acceptor(OtpNode node, int port) : base("OtpNode.Acceptor", true) { this.node = node; sock = new TcpListener(new IPEndPoint(IPAddress.Any, port)); sock.Start(); this.port = ((IPEndPoint)sock.LocalEndpoint).Port; node.port = this.port; publishPort(); base.start(); }
public static void Main(string[] args) { OtpNode a = new OtpNode("a"); OtpNode b = new OtpNode("b"); OtpActorMbox echo = (OtpActorMbox)b.createMbox("echo", false); b.react(new OtpEchoActor(echo)); OtpMbox echoback = a.createMbox("echoback", true); OtpErlangObject[] v = { echoback.Self, new OtpErlangString("Hello, World!") }; echoback.send(echo.Self, new OtpErlangTuple(v)); log.Debug("<- ECHO (back) " + echoback.receive()); b.close(); a.close(); }
public PCVMActor(Scene scene, IConfigSource source, OtpNode node, OtpActorMbox mbox) : base(mbox) { m_scene = scene; m_source = source; m_node = node; m_mbox = mbox; m_dict = new PCDict(); m_vm = new PCVM(m_scene, m_source, m_dict); }
public KernelActor(Scene scene, IConfigSource source, OtpNode node, OtpActorMbox mbox) : base(mbox) { m_scene = scene; m_source = source; m_node = node; m_mbox = mbox; }
public void Initialise(Scene scene, IConfigSource source) { m_scene = scene; m_source = source; try { m_node = new OtpNode("pc"); } catch (Exception e) { m_log.ErrorFormat("[Distributed PC] Failed to create an Erlang Node: {0}", e.Message); } }
/* * Intiate and open a connection to a remote node. */ internal OtpCookedConnection(OtpNode self, OtpPeer other) : base(self, other) { this.self = self; Start(); }
internal OtpActorMbox(OtpActorSched sched, OtpNode home, OtpErlangPid self) : base(home, self, null) { this.sched = sched; }
// package constructor: called by OtpNode:createMbox() // to create an anonymous internal OtpMbox(OtpNode home, OtpErlangPid self) : this(home, self, null) { }
public static void Main(string[] args) { OtpNode node = new OtpNode("gen"); OtpMbox mbox = node.createMbox(true); OtpErlangObject message = new OtpErlangTuple(new OtpErlangObject[] { mbox.Self, new OtpErlangAtom("new") }); mbox.send("kernel", "pc@3di0050d", message); OtpErlangTuple reply = (OtpErlangTuple)mbox.receive(); OtpErlangPid self = (OtpErlangPid)reply.elementAt(0); OtpErlangAtom ok = (OtpErlangAtom)reply.elementAt(1); OtpErlangPid pid = (OtpErlangPid)reply.elementAt(2); Console.WriteLine("New: {0}", ok); if (ok.ToString() != "ok") { return; } mbox.link(pid); Maze m = new Maze(50, 50); m.Generate(); string script = String.Empty; double z = 25.0; double w = 5.0; double h = 5.0; double d = 0.5; script += String.Format("/L {{moveto createbox dup <{0},{1},{2}> setsize dup show}} def\n", d, (w + d), h); script += String.Format("/B {{moveto createbox dup <{0},{1},{2}> setsize dup show}} def\n", (w + d), d, h); foreach (Cell c in m.Cell) { double x = ((float)c.X) * w + 3.0; double y = ((float)c.Y) * w + 3.0; if (c.Left) { script += String.Format("<{0},{1},{2}> L\n", x, (y + w / 2.0), (z + h / 2.0)); } if (c.Bottom) { script += String.Format("<{0},{1},{2}> B\n", (x + w / 2.0), y, (z + h / 2.0)); } } Load(mbox, pid, script); Console.WriteLine("Hit return key to continue"); Console.ReadLine(); mbox.send(pid, new OtpErlangTuple(new OtpErlangObject[] { mbox.Self, new OtpErlangAtom("exit") })); reply = (OtpErlangTuple)mbox.receive(); mbox.close(); node.close(); }
public static void Main(string[] args) { OtpNode node = new OtpNode("gen"); OtpMbox mbox = node.createMbox(true); OtpErlangObject message = new OtpErlangTuple(new OtpErlangObject[] { mbox.Self, new OtpErlangAtom("new") }); mbox.send("kernel", "pc@3di0050d", message); OtpErlangTuple reply = (OtpErlangTuple)mbox.receive(); OtpErlangPid self = (OtpErlangPid)reply.elementAt(0); OtpErlangAtom ok = (OtpErlangAtom)reply.elementAt(1); OtpErlangPid pid = (OtpErlangPid)reply.elementAt(2); Console.WriteLine("New: {0}", ok); if (ok.ToString() != "ok") { return; } mbox.link(pid); using (CUDA cuda = new CUDA(0, true)) { float deltaTime = 0.1f; int nextTickCount; using (NBody nbody = new NBody(cuda, deltaTime, 1.0f, 32)) { string script = String.Empty; nbody.Initialize(); script += String.Format("<128,128,50> translate\n"); script += String.Format("/C {{moveto createsphere dup <1,1,1> setsize dup show }} def\n"); for (int i = 0; i < nbody.HostOldPos.Length; i++) { Float4 pos = nbody.HostOldPos[i]; script += String.Format("<{0},{1},{2}> C /b{3} exch def\n", pos.x, pos.y, pos.z, i); } Load(mbox, pid, script); script = String.Empty; nextTickCount = System.Environment.TickCount; for (ulong frame = 0; frame < 300; frame++) { while (System.Environment.TickCount < nextTickCount); nextTickCount = nextTickCount + (int)(deltaTime * 1000); nbody.Update(0); nbody.Swap(); for (int i = 0; i < nbody.HostOldPos.Length; i++) { Float4 pos = nbody.HostOldPos[i]; script += String.Format("b{3} <{0},{1},{2}> setposition \n", pos.x, pos.y, pos.z, i); } Load(mbox, pid, script); script = String.Empty; } } } Console.WriteLine("Hit return key to continue"); Console.ReadLine(); mbox.send(pid, new OtpErlangTuple(new OtpErlangObject[] { mbox.Self, new OtpErlangAtom("exit") })); reply = (OtpErlangTuple)mbox.receive(); mbox.close(); node.close(); }
/** * package constructor: called by OtpNode:createMbox() to create an anonymous mbox */ internal OtpMbox(OtpNode home, OtpErlangPid self) : this(home, self, null) { }
/* * Accept an incoming connection from a remote node. Used by {@link * OtpSelf#accept() OtpSelf.accept()} to create a connection based on data * received when handshaking with the peer node, when the remote node is the * connection intitiator. */ internal OtpCookedConnection(OtpNode self, IOtpTransport s) : base(self, s) { this.self = self; Start(); }
public Mailboxes(OtpNode node, OtpActorSched sched) { this.node = node; this.sched = sched; byPid = new Dictionary<OtpErlangPid, WeakReference>(); byName = new Dictionary<String, WeakReference>(); }
internal OtpActorMbox(OtpActorSched sched, OtpNode home, OtpErlangPid self, String name) : base(home, self, name) { this.sched = sched; }