Exemple #1
0
        private static void DeleteContext(ref CleanupNotifier.RegistrationToken token)
        {
            object obj = CleanupNotifier.cleanupIdToContext;

            lock (obj) {
                CleanupNotifier.cleanupIdToContext.Remove(token.Identifier);
                token.Invalidate();
            }
        }
Exemple #2
0
        public static void UnregisterForCleanup(ref CleanupNotifier.RegistrationToken token)
        {
            object obj = CleanupNotifier.cleanupIdToContext;

            lock (obj) {
                CleanupNotifier.ObjectCleanupContext objectCleanupContext;
                if (CleanupNotifier.cleanupIdToContext.TryGetValue(token.Identifier, out objectCleanupContext))
                {
                    CleanupNotifierBridge.UnregisterCleanupDelegate(objectCleanupContext.CleanupObjectCPtr, objectCleanupContext.NotifyObjectCPtr);
                    CleanupNotifier.DeleteContext(ref token);
                    FirebaseApp.LogMessage(LogLevel.Debug, string.Format("{0} (instance 0x{1:X}) unregistered for cleanup when 0x{2:X} is destroyed", objectCleanupContext.NotifyObjectType, (long)objectCleanupContext.NotifyObjectCPtr, (long)objectCleanupContext.CleanupObjectCPtr));
                }
            }
        }
Exemple #3
0
 public static CleanupNotifier.RegistrationToken Create(object lockObject)
 {
     CleanupNotifier.RegistrationToken result;
     lock (lockObject) {
         if (CleanupNotifier.RegistrationToken.nextId == 0L)
         {
             CleanupNotifier.RegistrationToken.nextId += 1L;
         }
         CleanupNotifier.RegistrationToken registrationToken = new CleanupNotifier.RegistrationToken {
             Identifier = CleanupNotifier.RegistrationToken.nextId
         };
         CleanupNotifier.RegistrationToken.nextId += 1L;
         result = registrationToken;
     }
     return(result);
 }
Exemple #4
0
        public static void DisposeObject(ref CleanupNotifier.RegistrationToken token, object owner, bool delete)
        {
            object obj = CleanupNotifier.cleanupIdToContext;

            lock (obj) {
                CleanupNotifier.ObjectCleanupContext objectCleanupContext;
                if (CleanupNotifier.cleanupIdToContext.TryGetValue(token.Identifier, out objectCleanupContext))
                {
                    CleanupNotifier.DeleteContext(ref token);
                    if (!CleanupNotifierBridge.GetAndDestroyNotifiedFlag(objectCleanupContext.NotifyObjectCPtr) && delete)
                    {
                        FirebaseApp.LogMessage(LogLevel.Debug, string.Format("{0} (instance 0x{1:X}) being deleted", objectCleanupContext.NotifyObjectType, (long)objectCleanupContext.NotifyObjectCPtr));
                        objectCleanupContext.DeleteObject(new HandleRef(owner, objectCleanupContext.NotifyObjectCPtr));
                        FirebaseApp.LogMessage(LogLevel.Debug, string.Format("{0} (instance 0x{1:X}) deleted", objectCleanupContext.NotifyObjectType, (long)objectCleanupContext.NotifyObjectCPtr));
                    }
                }
            }
        }