Пример #1
0
    static int set_DownWWW(IntPtr L)
    {
        object        o   = LuaScriptMgr.GetLuaObject(L, 1);
        WaitCoroutine obj = (WaitCoroutine)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name DownWWW");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index DownWWW on a nil value");
            }
        }

        obj.DownWWW = (WWW)LuaScriptMgr.GetNetObject(L, 3, typeof(WWW));
        return(0);
    }
Пример #2
0
    static int set_isDoneCoroutine(IntPtr L)
    {
        object        o   = LuaScriptMgr.GetLuaObject(L, 1);
        WaitCoroutine obj = (WaitCoroutine)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name isDoneCoroutine");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index isDoneCoroutine on a nil value");
            }
        }

        obj.isDoneCoroutine = LuaScriptMgr.GetBoolean(L, 3);
        return(0);
    }
        public void CoroutineThreadIntShouldBePossibleToInterceptExceptionWithoutBlocking()
        {
            // ReSharper disable once ConvertToConstant.Local
            int hundred = 100;
            var ft      = new CoroutineThread(1);
            var first   = new WaitCoroutine(hundred);
            var second  = new WaitCoroutine(200)
            {
                ThrowsException = true
            };

            ft.AddCoroutine(first, second);
            ft.Start();
            Thread.Sleep(1000);
            ft.Pause();
            Thread.Sleep(300);

            Assert.IsTrue(second.Exceptions <= second.Cycles);

            var firstCycles  = first.Cycles;
            var secondCycles = second.Cycles;

            Assert.AreEqual(ft.Status, CoroutineThreadStatus.Paused);
            Thread.Sleep(1500);
            Assert.AreEqual(firstCycles, first.Cycles);
            Assert.AreEqual(secondCycles, second.Cycles);
            ft.Start();
            Thread.Sleep(300);
            Assert.AreEqual(CoroutineThreadStatus.Running, ft.Status);
            ft.Stop();
            Thread.Sleep(300);
            Assert.AreEqual(CoroutineThreadStatus.Stopped, ft.Status);

            Assert.IsTrue(firstCycles <= first.Cycles);
            Assert.IsTrue(secondCycles <= second.Cycles);

            Assert.IsTrue(second.Exceptions <= second.Cycles);
        }
        public void ShouldBeExecutedTheRightNumberOfCyclesByHundredsOfThingsDefaultThreads()
        {
            // ReSharper disable once ConvertToConstant.Local
            int hundred = 100;

            _reset = new ManualResetEvent(false);

            var threadContainer = new CoroutineThread(100);

            threadContainer.Start();

            var fl = new List <WaitCoroutine>();

            for (int i = 0; i < MULTIPLE_COUNT; i++)
            {
                var fb = new WaitCoroutine(hundred)
                {
                    Thread = threadContainer
                };
                fl.Add(fb);
                var flt = new Thread(ExecuteTimerCoroutine);
                flt.Start(fb);
            }
            _reset.Set();

            Thread.Sleep(1000);
            threadContainer.Stop();
            Thread.Sleep(300);
            var total = 0;

            foreach (var fb in fl)
            {
                total += fb.Cycles;
                Console.WriteLine("Result: " + fb.Cycles);
            }
            Console.WriteLine("Total: " + total);
            Assert.IsTrue(total < 100);
        }
Пример #5
0
 public override void ResetCachedDone(bool force = false)
 {
     _isDone        = false;
     _waitCoroutine = null;
 }
Пример #6
0
 private async Task<bool> Waiting()
 {
     DisablePulse();
     if (_waitCoroutine == null)
     {
         _waitCoroutine = new WaitCoroutine(5000);
     }
     if (!await _waitCoroutine.GetCoroutine()) return false;
     _waitCoroutine = null;
     State = States.Completed;
     return false;
 }
Пример #7
0
 public void WWWReconnectCall(string pUrl, string pName, WaitCoroutine done)
 {
     StartCoroutine(WWWReconnect(pUrl, pName, done));
 }