createMbox() public method

public createMbox ( String name, bool sync ) : Erlang.NET.OtpMbox
name String
sync bool
return Erlang.NET.OtpMbox
示例#1
0
 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();
 }
示例#2
0
        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();
        }
示例#3
0
        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();
        }