Exemple #1
0
 public Continuation(T inst, FrameScheduler scheduler)
 {
     instruction  = inst;
     continuation = null;
     owner        = null;
     Scheduler    = scheduler;
 }
Exemple #2
0
 public Continuation(T inst, IManageableObject owner, FrameScheduler scheduler)
 {
     instruction  = inst;
     continuation = null;
     this.owner   = owner;
     Scheduler    = scheduler;
 }
Exemple #3
0
 public Continuation(T inst)
 {
     instruction  = inst;
     continuation = null;
     owner        = null;
     Scheduler    = FrameScheduler.BeforeUpdate;
 }
Exemple #4
0
        /// <summary>
        /// Performs all scheduled disposal calls and cleans up internal data. This is done automatically at the
        /// end of each <see cref="Update">frame update</see> and you shouldn't need to call this in general.
        /// Invoking this method while an update is still in progress may result in undefined behavior. Don't do this.
        /// </summary>
        public static void RunCleanup()
        {
            // Perform scheduled object disposals
            object[] disposeScheduleArray;
            bool     lockTaken = false;

            try {
                disposeScheduleLock.Enter(ref lockTaken);
                disposeScheduleArray = disposeSchedule.ToArray();
                disposeSchedule.Clear();
            } finally {
                if (lockTaken)
                {
                    disposeScheduleLock.Exit();
                }
            }

            foreach (object o in disposeScheduleArray)
            {
                IManageableObject m = o as IManageableObject;
                if (m != null)
                {
                    m.Dispose(); continue;
                }
                IDisposable d = o as IDisposable;
                if (d != null)
                {
                    d.Dispose(); continue;
                }
            }

            // Perform late finalization and remove disposed object references
            Resource.RunCleanup();
            Scene.Current.RunCleanup();
        }
Exemple #5
0
 public Continuation(T inst, CancellationToken cancellationToken, FrameScheduler scheduler)
 {
     instruction            = inst;
     continuation           = null;
     owner                  = null;
     this.cancellationToken = cancellationToken;
     Scheduler              = scheduler;
 }
Exemple #6
0
 private static void RunCleanup()
 {
     foreach (object o in disposeSchedule)
     {
         IManageableObject m = o as IManageableObject;
         if (m != null)
         {
             m.Dispose(); continue;
         }
         IDisposable d = o as IDisposable;
         if (d != null)
         {
             d.Dispose(); continue;
         }
     }
     disposeSchedule.Clear();
     Resource.RunCleanup();
     Scene.Current.RunCleanup();
 }
Exemple #7
0
        /// <summary>
        /// Performs all scheduled disposal calls and cleans up internal data. This is done automatically at the
        /// end of each <see cref="Update()">frame update</see> and you shouldn't need to call this in general.
        /// Invoking this method while an update is still in progress may result in undefined behavior. Don't do this.
        /// </summary>
        public static void RunCleanup()
        {
            // Perform scheduled object disposals
            object[] disposeScheduleArray = disposeSchedule.ToArray();
            disposeSchedule.Clear();
            foreach (object o in disposeScheduleArray)
            {
                IManageableObject m = o as IManageableObject;
                if (m != null)
                {
                    m.Dispose(); continue;
                }
                IDisposable d = o as IDisposable;
                if (d != null)
                {
                    d.Dispose(); continue;
                }
            }

            // Perform late finalization and remove disposed object references
            Resource.RunCleanup();
        }
Exemple #8
0
        protected void LocalClearDisposed()
        {
            this.LocalClear(o =>
            {
                if (o == null)
                {
                    return(true);
                }

                IManageableObject manObj = o as IManageableObject;
                if (manObj != null && manObj.Disposed)
                {
                    return(true);
                }

                Resource resObj = o as Resource;
                if (resObj != null && resObj.Disposed)
                {
                    return(true);
                }

                return(false);
            });
        }
Exemple #9
0
 /// <summary>
 /// Link the <see cref="Duality.Async.IAwaitInstruction"/>'s lifespan to an object.
 /// </summary>
 /// <returns>A continuation with updated params.</returns>
 public static Continuation <T> ConfigureAwait <T>(this T @this, IManageableObject owner) where T : IAwaitInstruction
 => new Continuation <T>(@this).ConfigureAwait(owner);
Exemple #10
0
 public Continuation <T> ConfigureAwait(IManageableObject owner, FrameScheduler scheduler)
 {
     this.owner = owner;
     Scheduler  = scheduler;
     return(this);
 }
Exemple #11
0
 public Continuation <T> ConfigureAwait(IManageableObject owner)
 {
     this.owner = owner;
     return(this);
 }
Exemple #12
0
 /// <summary>
 /// Schedules this object for disposal at the end of the current update cycle.
 /// </summary>
 /// <param name="obj"></param>
 public static void DisposeLater(this IManageableObject obj)
 {
     DualityApp.DisposeLater(obj);
 }