Exemplo n.º 1
0
        public Coroutinesin(SET defautSetValue, RES defautResValue)
        {
            ResDefautValue = defautResValue;
            SetDefautValue = defautSetValue;
            var ptr = GCHandle.ToIntPtr(GCHandle.Alloc(this));

            FiberB   = RiberStatic.CreateFiberEx(0, 0, 1, fiberproc, ptr);
            ThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
        }
Exemplo n.º 2
0
        static void unmanaged_fiberproc(IntPtr arg)
        {
            GCHandle g = GCHandle.FromIntPtr(arg);
            Coroutinesin <SET, RES> tmp = g.Target as Coroutinesin <SET, RES>;

            g.Free();

            tmp.ExtIng();

            RiberStatic.SwitchToFiber(FiberA);
        }
Exemplo n.º 3
0
        public virtual void Dispose()
        {
            if (!IsDispose)
            {
                IsDispose = true;

                if (FiberB != IntPtr.Zero)
                {
                    RiberStatic.DeleteFiber(FiberB);
                    FiberB = IntPtr.Zero;
                }
            }


            state = FiberStateEnum.FiberStopped;
        }
Exemplo n.º 4
0
        void initialize_thread()
        {
            if (ThreadId != 0 && ThreadId != System.Threading.Thread.CurrentThread.ManagedThreadId)
            {
                throw new Exception("The Thread Not Use It");
            }

            if (!thread_is_fiber)
            {
                if (FiberA == IntPtr.Zero)
                {
                    FiberA = RiberStatic.ConvertThreadToFiberEx(0, 1);

                    if (FiberA == IntPtr.Zero)
                    {
                        throw new Exception("not ConvertThreadToFiber");
                    }
                }


                thread_is_fiber = true;
            }
        }
Exemplo n.º 5
0
 static void CorSwitchToFiber(IntPtr fiber)
 {
     RiberStatic.SwitchToFiber(fiber);
 }