Ejemplo 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;
                }
            }
        }
Ejemplo 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));
        }
Ejemplo n.º 3
0
 public override object run(ZoneCallback f)
 {
     if (ReferenceEquals(_current, async_._rootZone))
     {
         return(f());
     }
     return(async_._rootRun(null, null, this, f));
 }
Ejemplo 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);
        }
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo n.º 8
0
        internal static void _scheduleImmediate(ZoneCallback callback)
        {
            Isolate.ensureExists();

            GCHandle callabackHandle = GCHandle.Alloc(callback);

            UIMonoState_scheduleMicrotask(_scheduleMicrotask, (IntPtr)callabackHandle);
        }
Ejemplo 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);
        }
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo 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)));
        }
Ejemplo n.º 13
0
 public override object runGuarded(ZoneCallback f)
 {
     try {
         return(run(f));
     }
     catch (Exception e) {
         handleUncaughtError(e);
         return(null);
     }
 }
Ejemplo 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);
            }
        }
Ejemplo 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;
            }
        }
Ejemplo 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));
        }
Ejemplo n.º 17
0
        public override ZoneCallback bindCallbackGuarded(ZoneCallback f)
        {
            var registered = registerCallback(f);

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