public override Present Realize(string refCredit)
		{
			Monitor.Enter(this);
			Present result;
			try
			{
				if (this.activeAsyncRef != null)
				{
					result = this.activeAsyncRef.Duplicate(refCredit);
				}
				else
				{
					D.Assert(!this.realizing);
					this.realizing = true;
					this.activeAsyncRef = (AsyncRef)this.future.Realize("ODSPF");
					AsyncRef asyncRef = (AsyncRef)this.activeAsyncRef.Duplicate(refCredit);
					this.prioritizer.Realizing(this);
					this.activeAsyncRef.AddCallback(new AsyncRecord.CompleteCallback(this.AsyncCompleteCallback));
					result = asyncRef;
				}
			}
			finally
			{
				Monitor.Exit(this);
			}
			return result;
		}
		public PersistentInterest(AsyncRef asyncRef)
		{
			this.interestList = new InterestList();
			this.interestList.Add(asyncRef);
			this.interestList.Activate();
			asyncRef.AddCallback(new AsyncRecord.CompleteCallback(this.AsyncCompleteCallback));
		}
Example #3
0
 public PersistentInterest(AsyncRef asyncRef)
 {
     this.interestList = new InterestList();
     this.interestList.Add(asyncRef);
     this.interestList.Activate();
     asyncRef.AddCallback(new AsyncRecord.CompleteCallback(this.AsyncCompleteCallback));
 }
        public override Present Realize(string refCredit)
        {
            Monitor.Enter(this);
            Present result;

            try
            {
                if (activeAsyncRef != null)
                {
                    result = activeAsyncRef.Duplicate(refCredit);
                }
                else
                {
                    D.Assert(!realizing);
                    realizing      = true;
                    activeAsyncRef = (AsyncRef)future.Realize("ODSPF");
                    AsyncRef asyncRef = (AsyncRef)activeAsyncRef.Duplicate(refCredit);
                    prioritizer.Realizing(this);
                    activeAsyncRef.AddCallback(AsyncCompleteCallback);
                    result = asyncRef;
                }
            }
            finally
            {
                Monitor.Exit(this);
            }

            return(result);
        }
		private void RendererSanityCheckComplete(AsyncRef asyncRef)
		{
			Monitor.Enter(this);
			try
			{
				if (this.handled)
				{
					return;
				}
				this.handled = true;
			}
			finally
			{
				Monitor.Exit(this);
			}
			if (!(asyncRef.present is ImageRef))
			{
				if (asyncRef.present is RequestCanceledPresent)
				{
					new InsaneSourceMapRemover(this.sourceMap, this.mapTileSourceFactory, this.undoAddSourceMapDelegate, this.tryCount + 1);
					return;
				}
				string message;
				if (asyncRef.present is PresentFailureCode)
				{
					message = ((PresentFailureCode)asyncRef.present).exception.Message;
				}
				else
				{
					message = string.Format("Unexpected result type {0}", asyncRef.present.GetType().ToString());
				}
				this.undoAddSourceMapDelegate(message);
				return;
			}
		}
Example #6
0
		public AsyncRecord(AsyncScheduler scheduler, IFuture cacheKeyToEvict, IFuture future)
		{
			this._cacheKeyToEvict = cacheKeyToEvict;
			this._future = future;
			this.scheduler = scheduler;
			this._present = null;
			this.asyncState = AsyncState.Prequeued;
			this.queuePriority = 0;
			this.qtpRef = new AsyncRef(this, "qRef");
		}
Example #7
0
 public AsyncRecord(AsyncScheduler scheduler, IFuture cacheKeyToEvict, IFuture future)
 {
     this.cacheKeyToEvict = cacheKeyToEvict;
     this.future          = future;
     this.scheduler       = scheduler;
     present       = null;
     asyncState    = AsyncState.Prequeued;
     queuePriority = 0;
     qtpRef        = new AsyncRef(this, "qRef");
 }
		private void AsyncCompleteCallback(AsyncRef asyncRef)
		{
			Monitor.Enter(this);
			try
			{
				this.realizing = false;
				this.prioritizer.Complete(this);
				this.activeAsyncRef.Dispose();
				this.activeAsyncRef = null;
			}
			finally
			{
				Monitor.Exit(this);
			}
		}
 private void AsyncCompleteCallback(AsyncRef asyncRef)
 {
     Monitor.Enter(this);
     try
     {
         realizing = false;
         prioritizer.Complete(this);
         activeAsyncRef.Dispose();
         activeAsyncRef = null;
     }
     finally
     {
         Monitor.Exit(this);
     }
 }
Example #10
0
        public override Present Realize(string refCredit)
        {
            Present present = this.asyncFuture.Realize(refCredit);

            if (present is AsyncRef)
            {
                AsyncRef asyncRef = (AsyncRef)present;
                asyncRef.AddCallback(new AsyncRecord.CompleteCallback(this.PresentReadyCallback));
                asyncRef.SetInterest(this.interestValue);
                AsyncRef asyncRef2 = (AsyncRef)asyncRef.Duplicate(refCredit + "2");
                new PersistentInterest(asyncRef);
                this.asyncReadyEvent.WaitOne();
                return(asyncRef2.present);
            }
            return(present);
        }
 public void Dispose()
 {
     Monitor.Enter(this);
     try
     {
         if (activeAsyncRef != null)
         {
             activeAsyncRef.Dispose();
             activeAsyncRef = null;
         }
     }
     finally
     {
         Monitor.Exit(this);
     }
 }
Example #12
0
 private void Notify(Present presentValue)
 {
     Monitor.Enter(this);
     try
     {
         D.Assert(this._present == null);
         this._present        = presentValue;
         this.notificationRef = new AsyncRef(this, "callback");
         this.qtpRef          = null;
     }
     finally
     {
         Monitor.Exit(this);
     }
     DebugThreadInterrupter.theInstance.AddThread("AsyncRecord.NotifyThread", new ThreadStart(this.NotifyThread), ThreadPriority.Normal);
 }
Example #13
0
		public void AddCallback(AsyncRecord.CompleteCallback callback)
		{
			Monitor.Enter(this);
			try
			{
				if (this.present != null)
				{
					AsyncRef asyncRef = new AsyncRef(this, "AsyncRecord.AddCallback");
					callback(asyncRef);
					asyncRef.Dispose();
				}
				else
				{
					this.callbackEvent = (AsyncRecord.CompleteCallback)Delegate.Combine(this.callbackEvent, callback);
				}
			}
			finally
			{
				Monitor.Exit(this);
			}
		}
Example #14
0
 public void AddCallback(CompleteCallback callback)
 {
     Monitor.Enter(this);
     try
     {
         if (present != null)
         {
             AsyncRef asyncRef = new AsyncRef(this, "AsyncRecord.AddCallback");
             callback(asyncRef);
             asyncRef.Dispose();
         }
         else
         {
             callbackEvent = (CompleteCallback)Delegate.Combine(callbackEvent, callback);
         }
     }
     finally
     {
         Monitor.Exit(this);
     }
 }
Example #15
0
 internal void ChangePriority(AsyncRef asyncRef)
 {
     this.qtp.ChangePriority(asyncRef);
 }
Example #16
0
 private void BoundsRefAvailable(AsyncRef asyncRef)
 {
     base.Invalidate();
 }
Example #17
0
 public void AsyncRecordComplete(AsyncRef asyncRef)
 {
     if (this.viewerControl.asyncRequestGeneration == this.generation)
     {
         this.viewerControl.InvalidateView();
     }
 }
Example #18
0
 public void AsyncCompleteCallback(AsyncRef boundsAsyncRef)
 {
     this.interestList.Dispose();
 }
Example #19
0
		internal void EvictFromCache(AsyncRef aref)
		{
			this.asyncRecordCache.Evict(aref.asyncRecord.cacheKeyToEvict);
		}
		private void PresentReadyCallback(AsyncRef asyncRef)
		{
			this.asyncReadyEvent.Set();
		}
Example #21
0
		public void Add(AsyncRef aref)
		{
			this.list.AddLast(aref);
		}
		private void ImageBoundsAvailable(AsyncRef asyncRef)
		{
			this.StoreRenderRegion(asyncRef.present);
		}
Example #23
0
		private void Notify(Present presentValue)
		{
			Monitor.Enter(this);
			try
			{
				D.Assert(this._present == null);
				this._present = presentValue;
				this.notificationRef = new AsyncRef(this, "callback");
				this.qtpRef = null;
			}
			finally
			{
				Monitor.Exit(this);
			}
			DebugThreadInterrupter.theInstance.AddThread("AsyncRecord.NotifyThread", new ThreadStart(this.NotifyThread), ThreadPriority.Normal);
		}
Example #24
0
		internal void ChangePriority(AsyncRef asyncRef)
		{
			this.qtp.ChangePriority(asyncRef);
		}
Example #25
0
 public void Add(AsyncRef aref)
 {
     this.list.AddLast(aref);
 }
		public void Dispose()
		{
			Monitor.Enter(this);
			try
			{
				if (this.activeAsyncRef != null)
				{
					this.activeAsyncRef.Dispose();
					this.activeAsyncRef = null;
				}
			}
			finally
			{
				Monitor.Exit(this);
			}
		}
		public void AsyncCompleteCallback(AsyncRef boundsAsyncRef)
		{
			this.interestList.Dispose();
		}
			public void Callback(AsyncRef asyncRef)
			{
				this.lop.AsyncReadyCallback(this);
			}
Example #29
0
 private void PresentReadyCallback(AsyncRef asyncRef)
 {
     asyncReadyEvent.Set();
 }
Example #30
0
 internal void EvictFromCache(AsyncRef aref)
 {
     this.asyncRecordCache.Evict(aref.asyncRecord.cacheKeyToEvict);
 }