Ejemplo n.º 1
0
        private static void Register(KeepAliveCache cache)
        {
            if (cache == null)
            {
                throw new ArgumentNullException(nameof(cache));
            }

            lock (s_allCaches)
            {
                if (s_allCaches.Contains(cache))
                {
                    Report.Error($"[KeepAliveCache.Register] already registered ({cache.FriendlyName}).");
                }

                s_allCaches.Add(cache);
                Report.Warn($"[KeepAliveCache] registered {cache.FriendlyName}");

                if (s_allCaches.Count == 1)
                {
                    s_active = true;
                    new Thread(Keeper).Start();
                    new Thread(ConsoleLogger).Start();
                    // TODO: wait for startup of Keeper and Logger
                }
            }
        }
Ejemplo n.º 2
0
        private static void Unregister(KeepAliveCache cache)
        {
            if (cache == null)
            {
                throw new ArgumentNullException(nameof(cache));
            }

            lock (s_allCaches)
            {
                if (!s_allCaches.Contains(cache))
                {
                    Report.Error($"[KeepAliveCache.Unregister] not registered ({cache.FriendlyName}).");
                }

                s_allCaches.Remove(cache);
                Report.Warn($"[KeepAliveCache] unregistered {cache.FriendlyName}");

                if (s_allCaches.Count == 0)
                {
                    s_active = false;
                    // TODO: wait for shutdown of Keeper and Logger
                }
            }
        }