Exemplo n.º 1
0
 bool StrongRefByDefault(RefCounted refCounted)
 {
     if (refCounted is Scene)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
        void OnObjectDeleted(RefCounted refCounted, IntPtr handle)
        {
            if (refCounted.GetType() != objectType)
            {
                return;
            }

            managedSubscribersByObjects.Remove(handle);
            nativeSubscriptionsForObjects.Remove(handle);
        }
Exemplo n.º 3
0
        public void Add(RefCounted refCounted)
        {
            lock (knownObjects)
            {
                ReferenceHolder <RefCounted> knownObject;
                if (knownObjects.TryGetValue(refCounted.Handle, out knownObject))
                {
                    knownObject?.Reference?.Dispose();
                }

                knownObjects[refCounted.Handle] = new ReferenceHolder <RefCounted>(refCounted, weak: refCounted.Refs() < 1);
            }
        }
Exemplo n.º 4
0
		public void Add(RefCounted refCounted)
		{
			lock (knownObjects)
			{
				ReferenceHolder<RefCounted> knownObject;
				if (knownObjects.TryGetValue(refCounted.Handle, out knownObject))
				{
					knownObject?.Reference?.Dispose();
				}

				knownObjects[refCounted.Handle] = new ReferenceHolder<RefCounted>(refCounted, weak: refCounted.Refs() < 1);
			}
		}
Exemplo n.º 5
0
		public void Add(RefCounted refCounted)
		{
			lock (knownObjects)
			{
				ReferenceHolder<RefCounted> knownObject;
				if (knownObjects.TryGetValue(refCounted.Handle, out knownObject))
				{
					var existingObj = knownObject?.Reference;
					if (existingObj != null && !IsInHierarchy(existingObj.GetType(), refCounted.GetType()))
						throw new InvalidOperationException($"Handle '{refCounted.Handle}' is in use by '{existingObj.GetType().Name}' (IsDeleted={existingObj.IsDeleted}). {refCounted.GetType()}");
				}

				knownObjects[refCounted.Handle] = new ReferenceHolder<RefCounted>(refCounted, weak: refCounted.Refs() < 1 && !StrongRefByDefault(refCounted));
			}
		}
Exemplo n.º 6
0
        Dictionary<IntPtr, ReferenceHolder<RefCounted>> knownObjects = new Dictionary<IntPtr, ReferenceHolder<RefCounted>>(256); //based on samples (average)

        #endregion Fields

        #region Methods

        public void Add(RefCounted refCounted)
        {
            lock (knownObjects)
            {
                ReferenceHolder<RefCounted> knownObject;
                if (knownObjects.TryGetValue(refCounted.Handle, out knownObject))
                {
                    var existingObj = knownObject?.Reference;
                    if (existingObj != null)
                        throw new InvalidOperationException($"Handle '{refCounted.Handle}' is in use by '{existingObj.GetType().Name}' (IsDeleted={existingObj.IsDeleted}");
                }

                knownObjects[refCounted.Handle] = new ReferenceHolder<RefCounted>(refCounted, weak: refCounted.Refs() < 1 && !StrongRefByDefault(refCounted));
            }
        }
Exemplo n.º 7
0
 public static void RegisterObject(RefCounted refCounted)
 {
     RefCountedCache.Add(refCounted);
 }
Exemplo n.º 8
0
		bool StrongRefByDefault(RefCounted refCounted)
		{
			if (refCounted is Scene) return true;
			if (refCounted is Context) return true;
			return false;
		}
Exemplo n.º 9
0
 bool StrongRefByDefault(RefCounted refCounted)
 {
     if (refCounted is Scene)
         return true;
     return false;
 }