Beispiel #1
0
        public void MultipleDispose()
        {
            var visited = false;

            Sample();
            Assert.IsTrue(visited);

            var dispose1 = React.Scope(out var scope1);
            var r        = Outer(scope1);

            dispose1.Dispose();
            Asr.IsTrue(r.GetAwaiter().IsCompleted);

            async Routine Outer(IScope scope)
            {
                var res = await Sample().DisposeOn(scope);

                Asr.IsFalse(res.HasValue);
            }

            async Routine <int> Sample()
            {
                visited = true;
                await _Never.Instance;

                return(42);
            }
        }
Beispiel #2
0
        public void Unsubscribe(Action dispose)
        {
            if (Disposed || Disposing)
            {
                Asr.Fail("Cannot unsubscribe during or after disposal");
                return;
            }

            var any = _stack.Remove(dispose);

            Asr.IsTrue(any, "Delegate not found: make sure it's the same which was passed to OnDispose");
        }
Beispiel #3
0
        void _Init(ScheduleSettings scheduleSettings)
        {
            Asr.IsTrue(_instance == this);

            _dispose   = React.Scope(out var scope);
            Sch.Scope  = scope;
            _completed = false;

            Sch.Logic                           = StartSch(scheduleSettings.Logic, scope);
            (_update, Sch.Update)               = scope.PubSub();
            (_lateUpdate, Sch.LateUpdate)       = scope.PubSub();
            (_fixedUpdate, Sch.Physics)         = scope.PubSub();
            (_updateTime, Sch.UpdateTime)       = scope.PubSub <float>();
            (_fixedUpdateTime, Sch.PhysicsTime) = scope.PubSub <float>();
            (SchPub.PublishError, Sch.OnError)  = Sch.Scope.PubSub <Exception>();
        }
Beispiel #4
0
        public void Publish()
        {
            if (_completed)
            {
                Asr.Fail("Tried to publish Next to IPub which is completed");
                return;
            }


            Asr.IsTrue(_current.Count == 0);
            Swap();
            Run(_current, _next);

            void Swap()
            {
                var tmp = _current;

                _current = _next;
                _next    = tmp;
            }
        }