Beispiel #1
0
        public void DoLowerJob(Socket sock)
        {
            Comm.ReceiveInput(ref NetC);
            lock (LockObj) NetC.IsDoneLoadingInput = true;

            bool hasResultTo = true;

            while (NetC.HasSeedFrom || hasResultTo)
            {
                bool ynSeed = UnitSeed - Comm.GetCount(NetC.SiBef) > 0;
                SendReceive.SendPrimitive(sock, ynSeed);

                if (ynSeed)
                {
                    bool ynSeed2 = SendReceive.ReceivePrimitive <bool>(sock);

                    if (ynSeed2)
                    {
                        SeedIndex     siTemp   = default(SeedIndex);
                        SeedContainer sConTemp = default(SeedContainer);
                        Comm.ReceiveSeed(ref siTemp, ref sConTemp);
                        lock (LockObj) Comm.PutSeed(siTemp, sConTemp, ref NetC);
                    }
                }

                bool ynResult = Comm.GetCount(NetC.SiAft) > UnitSeed ||
                                (!NetC.HasSeedFrom && Comm.GetCount(NetC.SiAft) > 0);
                SendReceive.SendPrimitive(sock, ynResult);

                if (ynResult)
                {
                    SeedIndex       siTemp   = default(SeedIndex);
                    ResultContainer rConTemp = default(ResultContainer);
                    lock (LockObj) Comm.PullResult(ref NetC, ref siTemp, ref rConTemp);
                    ResultContainer rConMerged = default(ResultContainer);
                    Comm.MergeResult(rConTemp, ref rConMerged);
                    Comm.SendResult(siTemp, rConMerged);
                }

                lock (LockObj) NetC.HasSeedFrom = SendReceive.ReceivePrimitive <bool>(sock);
                hasResultTo = Comm.GetCount(NetC.SiBef) > 0 ||
                              Comm.GetCount(NetC.SiAllo) > 0 ||
                              Comm.GetCount(NetC.SiAft) > 0;
                SendReceive.SendPrimitive(sock, hasResultTo);
            }
        }
Beispiel #2
0
        public void DoUpperJob(Socket sock)
        {
            while (!NetC.IsDoneLoadingInput)
            {
            }
            Comm.SendInput(NetC);

            bool hasSeedTo     = true;
            bool hasResultFrom = true;

            while (hasSeedTo || hasResultFrom)
            {
                bool ynSeed = SendReceive.ReceivePrimitive <bool>(sock);
                if (ynSeed)
                {
                    SeedIndex     siTemp   = default(SeedIndex);
                    SeedContainer sConTemp = default(SeedContainer);
                    lock (LockObj) Comm.PullSeed(ref NetC, ref siTemp, ref sConTemp);

                    bool ynSeed2 = Comm.GetCount(siTemp) > 0;
                    SendReceive.SendPrimitive(sock, ynSeed2);
                    if (ynSeed2)
                    {
                        Comm.SendSeed(ref siTemp, ref sConTemp);
                    }
                }

                bool ynResult = SendReceive.ReceivePrimitive <bool>(sock);
                if (ynResult)
                {
                    SeedIndex       siTemp   = default(SeedIndex);
                    ResultContainer rConTemp = default(ResultContainer);
                    Comm.ReceiveResult(ref siTemp, ref rConTemp);
                    lock (LockObj) Comm.PutResult(siTemp, rConTemp, ref NetC);
                }

                hasSeedTo = (NetC.HasSeedFrom || Comm.GetCount(NetC.SiBef) > 0);
                SendReceive.SendPrimitive(sock, hasSeedTo);
                hasResultFrom = SendReceive.ReceivePrimitive <bool>(sock);
            }
        }