示例#1
0
        public unsafe Task Start(ArgMap args)
        {
            return(Task.Run(() =>
            {
                Passed = true;

                var p = stackalloc NoRefsStruct[1];
                var str = p[0];

                str.Int = int1;
                str.Dbl = dbl1;

                var mps = MarshalSlot.Store(str);
                Task.Run(() => useParkingSlot(mps));

                var p2 = MarshalSlot.Reserve <NoRefsStruct>(out MarshalSlot mps2);
                p2->Int = int2;
                p2->Dbl = dbl2;

                Task.Run(() => useParkingSlot(mps2));

                var mpsLarge = new MarshalSlot(20000000);
                mpsLarge.Span().Fill(7);
            }));
        }
示例#2
0
        void useParkingSlot(MarshalSlot mps)
        {
            var str = mps.Load <NoRefsStruct>();

            Print.AsInfo("Int: {0}, Dbl: {1}", str.Int, str.Dbl);

            if ((str.Int != int1 && str.Int != int2) ||
                (str.Dbl != dbl1 && str.Dbl != dbl2))
            {
                Passed = false;
            }
        }
示例#3
0
        async Task entry_point(Exchange ix)
        {
            if (!ix.RawBits)
            {
                throw new ArgumentException("rawBits");
            }

            var      ms   = new MarshalSlot(4);
            Exchange x    = ix;
            int      data = 0;

            try
            {
                x.Fragment.Read(ref data, x.DataOffset);

                while (data > 0 && !x.DoNotReply)
                {
                    data--;

                    ms.Write(data, 0);
                    x = await x.RawReply(ms, data < 1, true, TIMEOUT);

                    if (!x.IsOK)
                    {
                        Passed         = false;
                        FailureMessage = "Timeout";
                        return;
                    }

                    if (x.State == XState.Beamed)
                    {
                        x.Fragment.Read(ref data, x.DataOffset);
                    }
                }
            }
            finally
            {
                ms.Dispose();
                x.Dispose();
            }
        }
示例#4
0
        public async Task Start(IDictionary <string, List <string> > args)
        {
            var ta = new TestArgs(args);
            var s  = ta.AE;
            var t  = ta.BE;
            var a  = new XPU(new XCfg(
                                 new BeamerCfg()
            {
                Log = new BeamerLogCfg("a", ta.Log)
            },
                                 new XLogCfg("a-Replies", ta.Log),
                                 new HeapHighway(ushort.MaxValue)));

            var b = new XPU(new XCfg(
                                new BeamerCfg()
            {
                Log = new BeamerLogCfg("b", ta.Log)
            },
                                new XLogCfg("b-Replies", ta.Log),
                                new HeapHighway(ushort.MaxValue)));

            MarshalSlot ms = null;

            try
            {
                b.RegisterAPI("ep", entry_point);

                a.Start(s, t);
                b.Start(t, s);

                await a.TargetIsActive();

                await b.TargetIsActive();

                ms = MarshalSlot.Store(8);

                var x = await a.RawRequest("ep", ms, false, TIMEOUT);

                int data = 0;
                x.Fragment.Read(ref data, x.DataOffset);

                while (data > 0 && !x.DoNotReply)
                {
                    data--;
                    ms.Write(data, 0);

                    x = await x.RawReply(ms, data < 1, true, TIMEOUT);

                    if (!x.IsOK)
                    {
                        Passed         = false;
                        FailureMessage = "Timeout";
                        return;
                    }

                    if (x.State == XState.Beamed)
                    {
                        x.Fragment.Read(ref data, x.DataOffset);
                    }
                }

                await Task.Delay(TIMEOUT.Milliseconds * 3);

                if (!Passed.HasValue)
                {
                    Passed     = true;
                    IsComplete = true;
                }
            }
            catch (Exception ex)
            {
                Passed         = false;
                FailureMessage = ex.ToString();
            }
            finally
            {
                a.Dispose();
                b.Dispose();
                ms.Dispose();
            }
        }