Esempio n. 1
0
        static void _schedulePriorityAsyncCallback(ZoneCallback callback)
        {
            var state = _getState();

            if (state._nextCallback == null)
            {
                _scheduleAsyncCallback(callback);
                state._lastPriorityCallback = state._lastCallback;
                return;
            }

            _AsyncCallbackEntry entry = new _AsyncCallbackEntry(callback);

            if (state._lastPriorityCallback == null)
            {
                entry.next          = state._nextCallback;
                state._nextCallback = state._lastPriorityCallback = entry;
            }
            else
            {
                entry.next = state._lastPriorityCallback.next;
                state._lastPriorityCallback.next = entry;
                state._lastPriorityCallback      = entry;
                if (entry.next == null)
                {
                    state._lastCallback = entry;
                }
            }
        }
Esempio n. 2
0
        public ZoneCallback registerCallback(Zone zone, ZoneCallback f)
        {
            var   implementation            = _delegationTarget._registerCallback;
            _Zone implZone                  = implementation.zone;
            RegisterCallbackHandler handler = implementation.function;

            return(handler(implZone, async_._parentDelegate(implZone), zone, f));
        }
Esempio n. 3
0
 public override object run(ZoneCallback f)
 {
     if (ReferenceEquals(_current, async_._rootZone))
     {
         return(f());
     }
     return(async_._rootRun(null, null, this, f));
 }
Esempio n. 4
0
        public void scheduleMicrotask(Zone zone, ZoneCallback f)
        {
            var   implementation             = _delegationTarget._scheduleMicrotask;
            _Zone implZone                   = implementation.zone;
            ScheduleMicrotaskHandler handler = implementation.function;

            handler(implZone, async_._parentDelegate(implZone), zone, f);
        }
Esempio n. 5
0
        public Timer createTimer(Zone zone, TimeSpan duration, ZoneCallback f)
        {
            var   implementation       = _delegationTarget._createTimer;
            _Zone implZone             = implementation.zone;
            CreateTimerHandler handler = implementation.function;

            return(handler(implZone, async_._parentDelegate(implZone), zone, duration, f));
        }
Esempio n. 6
0
        public override object run(ZoneCallback f)
        {
            var          implementation = _run;
            ZoneDelegate parentDelegate = async_._parentDelegate(implementation.zone);
            RunHandler   handler        = implementation.function;

            return(handler(implementation.zone, parentDelegate, this, f));
        }
Esempio n. 7
0
        public override ZoneCallback registerCallback(ZoneCallback callback)
        {
            var                     implementation = _registerCallback;
            ZoneDelegate            parentDelegate = async_._parentDelegate(implementation.zone);
            RegisterCallbackHandler handler        = implementation.function;

            return(handler(implementation.zone, parentDelegate, this, callback));
        }
Esempio n. 8
0
        internal static void _scheduleImmediate(ZoneCallback callback)
        {
            Isolate.ensureExists();

            GCHandle callabackHandle = GCHandle.Alloc(callback);

            UIMonoState_scheduleMicrotask(_scheduleMicrotask, (IntPtr)callabackHandle);
        }
Esempio n. 9
0
        public override void scheduleMicrotask(ZoneCallback f)
        {
            var                      implementation = _scheduleMicrotask;
            ZoneDelegate             parentDelegate = async_._parentDelegate(implementation.zone);
            ScheduleMicrotaskHandler handler        = implementation.function;

            handler(implementation.zone, parentDelegate, this, f);
        }
Esempio n. 10
0
        public object run(Zone zone, ZoneCallback f)
        {
            var        implementation = _delegationTarget._run;
            _Zone      implZone       = implementation.zone;
            RunHandler handler        = implementation.function;

            return(handler(implZone, async_._parentDelegate(implZone), zone, f));
        }
Esempio n. 11
0
        public override Timer createTimer(TimeSpan duration, ZoneCallback f)
        {
            var                implementation = _createTimer;
            ZoneDelegate       parentDelegate = async_._parentDelegate(implementation.zone);
            CreateTimerHandler handler        = implementation.function;

            return(handler(implementation.zone, parentDelegate, this, duration, f));
        }
Esempio n. 12
0
        public static Timer create(TimeSpan duration, ZoneCallback callback)
        {
            if (Zone.current == Zone.root)
            {
                return(Zone.current.createTimer(duration, callback));
            }

            return(Zone.current
                   .createTimer(duration, Zone.current.bindCallbackGuarded(callback)));
        }
Esempio n. 13
0
 public override object runGuarded(ZoneCallback f)
 {
     try {
         return(run(f));
     }
     catch (Exception e) {
         handleUncaughtError(e);
         return(null);
     }
 }
Esempio n. 14
0
        public override object runGuarded(ZoneCallback f)
        {
            try {
                if (ReferenceEquals(async_._rootZone, _current))
                {
                    return(f());
                }

                return(async_._rootRun(null, null, this, f));
            }
            catch (Exception e) {
                handleUncaughtError(e);
                return(null);
            }
        }
Esempio n. 15
0
        static void _scheduleAsyncCallback(ZoneCallback callback)
        {
            var state = _getState();
            _AsyncCallbackEntry newEntry = new _AsyncCallbackEntry(callback);

            if (state._nextCallback == null)
            {
                state._nextCallback = state._lastCallback = newEntry;
                if (!state._isInCallbackLoop)
                {
                    _AsyncRun._scheduleImmediate(_startMicrotaskLoop);
                }
            }
            else
            {
                state._lastCallback.next = newEntry;
                state._lastCallback      = newEntry;
            }
        }
Esempio n. 16
0
        public static void scheduleMicrotask(ZoneCallback callback)
        {
            _Zone currentZone = (_Zone)Zone.current;

            if (ReferenceEquals(_rootZone, currentZone))
            {
                // No need to bind the callback. We know that the root's scheduleMicrotask
                // will be invoked in the root zone.
                _rootScheduleMicrotask(null, null, _rootZone, callback);
                return;
            }

            _ZoneFunction <ScheduleMicrotaskHandler> implementation = currentZone._scheduleMicrotask;

            if (ReferenceEquals(_rootZone, implementation.zone) &&
                _rootZone.inSameErrorZone(currentZone))
            {
                _rootScheduleMicrotask(
                    null, null, currentZone, currentZone.registerCallback(callback));
                return;
            }

            Zone.current.scheduleMicrotask(Zone.current.bindCallbackGuarded(callback));
        }
Esempio n. 17
0
        public override ZoneCallback bindCallbackGuarded(ZoneCallback f)
        {
            var registered = registerCallback(f);

            return(() => runGuarded(registered));
        }
Esempio n. 18
0
 public override ZoneCallback bindCallback(ZoneCallback f)
 {
     return(() => run(f));
 }
Esempio n. 19
0
 public override ZoneCallback bindCallbackGuarded(ZoneCallback f)
 {
     return(() => runGuarded(f));
 }
Esempio n. 20
0
 public abstract object run(ZoneCallback action);
Esempio n. 21
0
 public override void scheduleMicrotask(ZoneCallback f)
 {
     async_._rootScheduleMicrotask(null, null, this, f);
 }
Esempio n. 22
0
 public abstract Timer createTimer(TimeSpan duration, ZoneCallback callback);
Esempio n. 23
0
 public abstract void scheduleMicrotask(ZoneCallback callback);
Esempio n. 24
0
 public abstract ZoneCallback bindCallbackGuarded(ZoneCallback callback);
Esempio n. 25
0
 public abstract ZoneCallback bindCallback(ZoneCallback callback);
Esempio n. 26
0
 internal _AsyncCallbackEntry(ZoneCallback callback)
 {
     this.callback = callback;
 }
Esempio n. 27
0
 public abstract object runGuarded(ZoneCallback action);
Esempio n. 28
0
 public override ZoneCallback registerCallback(ZoneCallback f) => f;
Esempio n. 29
0
 public abstract ZoneCallback registerCallback(ZoneCallback callback);
Esempio n. 30
0
 public override Timer createTimer(TimeSpan duration, ZoneCallback f)
 {
     return(Timer._createTimer(duration, f));
 }