public LifecycledComponentsReleasePolicy(ITrackedComponentsDiagnostic trackedComponentsDiagnostic)
		{
			this.trackedComponentsDiagnostic = trackedComponentsDiagnostic;

			if (trackedComponentsDiagnostic != null)
			{
				trackedComponentsDiagnostic.TrackedInstancesRequested += trackedComponentsDiagnostic_TrackedInstancesRequested;
			}
		}
Exemple #2
0
        public LifecycledComponentsReleasePolicy(ITrackedComponentsDiagnostic trackedComponentsDiagnostic)
        {
            this.trackedComponentsDiagnostic = trackedComponentsDiagnostic;

            if (trackedComponentsDiagnostic != null)
            {
                trackedComponentsDiagnostic.TrackedInstancesRequested += trackedComponentsDiagnostic_TrackedInstancesRequested;
            }
        }
        public LifecycledComponentsReleasePolicy(ITrackedComponentsDiagnostic trackedComponentsDiagnostic, IPerformanceCounter countOfTrackedInstances)
        {
            this.trackedComponentsDiagnostic = trackedComponentsDiagnostic;
            this.countOfTrackedInstances     = countOfTrackedInstances;

            if (trackedComponentsDiagnostic != null)
            {
                trackedComponentsDiagnostic.TrackedInstancesRequested += trackedComponentsDiagnostic_TrackedInstancesRequested;
            }
        }
		public LifecycledComponentsReleasePolicy(ITrackedComponentsDiagnostic trackedComponentsDiagnostic, IPerformanceCounter countOfTrackedInstances)
		{
			this.trackedComponentsDiagnostic = trackedComponentsDiagnostic;
			this.countOfTrackedInstances = countOfTrackedInstances;

			if (trackedComponentsDiagnostic != null)
			{
				trackedComponentsDiagnostic.TrackedInstancesRequested += trackedComponentsDiagnostic_TrackedInstancesRequested;
			}
		}
		public LifecycledComponentsReleasePolicy(ITrackedComponentsDiagnostic trackedComponentsDiagnostic,
		                                         ITrackedComponentsPerformanceCounter trackedComponentsPerformanceCounter)
		{
			this.trackedComponentsDiagnostic = trackedComponentsDiagnostic;
			perfCounter = trackedComponentsPerformanceCounter ?? NullPerformanceCounter.Instance;

			if (trackedComponentsDiagnostic != null)
			{
				trackedComponentsDiagnostic.TrackedInstancesRequested += trackedComponentsDiagnostic_TrackedInstancesRequested;
			}
		}
Exemple #6
0
        /// <summary>
        ///   Creates new policy which publishes its tracking components count to <paramref
        ///    name = "trackedComponentsPerformanceCounter" /> and exposes diagnostics into <paramref
        ///    name = "trackedComponentsDiagnostic" />.
        /// </summary>
        /// <param name = "trackedComponentsDiagnostic"></param>
        /// <param name = "trackedComponentsPerformanceCounter"></param>
        public LifecycledComponentsReleasePolicy(ITrackedComponentsDiagnostic trackedComponentsDiagnostic,
                                                 ITrackedComponentsPerformanceCounter trackedComponentsPerformanceCounter)
        {
            this.trackedComponentsDiagnostic = trackedComponentsDiagnostic;
            perfCounter = trackedComponentsPerformanceCounter ?? NullPerformanceCounter.Instance;

            if (trackedComponentsDiagnostic != null)
            {
                trackedComponentsDiagnostic.TrackedInstancesRequested += trackedComponentsDiagnostic_TrackedInstancesRequested;
            }
        }
Exemple #7
0
 public void Dispose()
 {
     using (@lock.ForWriting())
     {
         if (trackedComponentsDiagnostic != null)
         {
             trackedComponentsDiagnostic.TrackedInstancesRequested -= trackedComponentsDiagnostic_TrackedInstancesRequested;
             trackedComponentsDiagnostic = null;
         }
         var burdens = instance2Burden.ToArray();
         instance2Burden.Clear();
         // NOTE: This is relying on a undocumented behavior that order of items when enumerating Dictionary<> will be oldest --> latest
         foreach (var burden in burdens.Reverse())
         {
             burden.Value.Release();
         }
     }
 }
		public void Dispose()
		{
			using (@lock.ForWriting())
			{
				if (trackedComponentsDiagnostic != null)
				{
					trackedComponentsDiagnostic.TrackedInstancesRequested -= trackedComponentsDiagnostic_TrackedInstancesRequested;
					trackedComponentsDiagnostic = null;
				}
				var burdens = instance2Burden.ToArray();
				instance2Burden.Clear();
				// NOTE: This is relying on a undocumented behavior that order of items when enumerating Dictionary<> will be oldest --> latest
				foreach (var burden in burdens.Reverse())
				{
					burden.Value.Release();
				}
			}
		}
Exemple #9
0
 public void Dispose()
 {
     KeyValuePair <object, Burden>[] burdens;
     using (@lock.ForWriting())
     {
         if (trackedComponentsDiagnostic != null)
         {
             trackedComponentsDiagnostic.TrackedInstancesRequested -= trackedComponentsDiagnostic_TrackedInstancesRequested;
             trackedComponentsDiagnostic = null;
         }
         burdens = instance2Burden.ToArray();
         instance2Burden.Clear();
     }
     // NOTE: This is relying on a undocumented behavior that order of items when enumerating Dictionary<> will be oldest --> latest
     foreach (var burden in burdens.Reverse())
     {
         burden.Value.Released -= OnInstanceReleased;
         perfCounter.DecrementTrackedInstancesCount();
         burden.Value.Release();
     }
 }
 public UnmanagedReleasePolicy(ITrackedComponentsDiagnostic trackedComponentsDiagnostic, ITrackedComponentsPerformanceCounter trackedComponentsPerformanceCounter)
     : base(trackedComponentsDiagnostic, trackedComponentsPerformanceCounter)
 {
 }
 public LifecycledComponentsReleasePolicy(ITrackedComponentsDiagnostic trackedComponentsDiagnostic, ITrackedComponentsPerformanceCounter trackedComponentsPerformanceCounter) : base(trackedComponentsDiagnostic, trackedComponentsPerformanceCounter)
 {
 }
		public void Dispose()
		{
			KeyValuePair<object, Burden>[] burdens;
			using (@lock.ForWriting())
			{
				if (trackedComponentsDiagnostic != null)
				{
					trackedComponentsDiagnostic.TrackedInstancesRequested -= trackedComponentsDiagnostic_TrackedInstancesRequested;
					trackedComponentsDiagnostic = null;
				}
				burdens = instance2Burden.ToArray();
				instance2Burden.Clear();
			}
			// NOTE: This is relying on a undocumented behavior that order of items when enumerating Dictionary<> will be oldest --> latest
			foreach (var burden in burdens.Reverse())
			{
				burden.Value.Released -= OnInstanceReleased;
				perfCounter.DecrementTrackedInstancesCount();
				burden.Value.Release();
			}
		}
Exemple #13
0
 public UnmanagedReleasePolicy(ITrackedComponentsDiagnostic trackedComponentsDiagnostic, ITrackedComponentsPerformanceCounter trackedComponentsPerformanceCounter)
     : base(trackedComponentsDiagnostic, trackedComponentsPerformanceCounter)
 {
 }
		public LifecycledComponentsReleasePolicy(ITrackedComponentsDiagnostic trackedComponentsDiagnostic)
			: this(trackedComponentsDiagnostic, NullPerformanceCounter.Instance)
		{
		}
Exemple #15
0
 /// <summary></summary>
 public TrulyTransientReleasePolicy(ITrackedComponentsDiagnostic trackedComponentsDiagnostic, ITrackedComponentsPerformanceCounter trackedComponentsPerformanceCounter) : base(trackedComponentsDiagnostic, trackedComponentsPerformanceCounter)
 {
 }
		/// <summary></summary>
		public TrulyTransientReleasePolicy(ITrackedComponentsDiagnostic trackedComponentsDiagnostic, ITrackedComponentsPerformanceCounter trackedComponentsPerformanceCounter) : base(trackedComponentsDiagnostic, trackedComponentsPerformanceCounter) {
		}
 public LifecycledComponentsReleasePolicy(ITrackedComponentsDiagnostic trackedComponentsDiagnostic)
     : this(trackedComponentsDiagnostic, NullPerformanceCounter.Instance)
 {
 }