Exemple #1
0
        IEnumerator testCothread()
        {
            var ev = new CothreadEvent();

            yield return(hub.StartCoroutine(_testEvent2(ev)));

            if (ev.Get().Equals(1))
            {
                CothreadHub.Log("[testCothread] ok");
            }
            else
            {
                CothreadHub.Log("[testCothread] error");
            }
        }
Exemple #2
0
        IEnumerator _testEvent1(int i, CothreadEvent ev, CothreadEvent nev)
        {
            yield return(ev.Wait(0));

            var result = (string)ev.Get("");
            var msg    = string.Format("{0} {1} ->", result, i.ToString());

            if (nev != null)
            {
                nev.Set(msg);
            }
            else
            {
                CothreadHub.Log("result: " + msg);
            }
        }
Exemple #3
0
        void testEvent1(int count)
        {
            CothreadEvent ev, nev, bev;

            bev = ev = new CothreadEvent();
            for (int i = 0; i < count; i++)
            {
                if (i + 1 == count)
                {
                    nev = null;
                }
                else
                {
                    nev = new CothreadEvent();
                }
                hub.StartCoroutine(_testEvent1(i + 1, ev, nev));
                ev = nev;
            }
            bev.Set("event");
        }
Exemple #4
0
        IEnumerator testU3dStartCothread()
        {
            var ev  = new CothreadEvent();
            var obj = GameObject.CreatePrimitive(PrimitiveType.Cube);
            var th  = hub.StartCothread(_testEvent2(ev), obj);

            yield return(hub.Sleep(10));

            GameObject.Destroy(obj);
            yield return(hub.Sleep(100));

            if (th.Closed && ev.Get() == null)
            {
                CothreadHub.Log("[testU3dStartCothread] ok");
            }
            else
            {
                CothreadHub.Log("[testU3dStartCothread] error");
            }
        }
Exemple #5
0
        IEnumerator testEvent2()
        {
            var ev = new CothreadEvent();

            hub.StartCoroutine(_testEvent2(ev));
            yield return(ev.Wait());

            if (!ev.Get().Equals(1))
            {
                CothreadHub.Log("[testEvent2] error");
            }
            else
            {
                CothreadHub.Log("[testEvent2] ok");
            }
            ev.Clear();
            hub.StartCoroutine(_testEvent2(ev));
            yield return(ev);

            AssertDebug.Assert(ev.Get().Equals(1), "[testEvent2] yield event error!");
        }
Exemple #6
0
 public void Close()
 {
     if (Closed)
     {
         return;
     }
     Closed = true;
     if (_ev != null)
     {
         try
         {
             _ev.Set(this);
         }
         catch (Exception err)
         {
             CothreadHub.Log(err);
         }
         _ev = null;
     }
     CothreadHub.Instance.delCothread(IE);
 }
Exemple #7
0
        IEnumerator _testEvent2(CothreadEvent ev)
        {
            yield return(hub.Sleep(1000));

            ev.Set(1);
        }