Exemplo n.º 1
0
        public bool Remove(UUID scope, GridRegion region)
        {
            if (region == null)
            {
                return(false);
            }

            if (!Monitor.TryEnter(syncRoot, MAX_LOCK_WAIT))
            {
                throw new ApplicationException("Lock could not be acquired after " + MAX_LOCK_WAIT + "ms");
            }
            try
            {
                RegionInfoForScope ris = null;
                if (!InfobyScope.TryGetValue(scope, out ris) || ris == null)
                {
                    return(false);
                }

                ris.Remove(region);
                if (ris.Count() == 0)
                {
                    InfobyScope.Remove(scope);
                }
                return(true);
            }
            finally { Monitor.Exit(syncRoot); }
        }
Exemplo n.º 2
0
        public bool AddOrUpdate(UUID scope, GridRegion region, float expirationSeconds)
        {
            if (region == null)
            {
                return(false);
            }

            if (!Monitor.TryEnter(syncRoot, MAX_LOCK_WAIT))
            {
                throw new ApplicationException("Lock could not be acquired after " + MAX_LOCK_WAIT + "ms");
            }

            try
            {
                DateTime expire = DateTime.UtcNow + TimeSpan.FromSeconds(expirationSeconds);

                RegionInfoForScope ris = null;
                if (!InfobyScope.TryGetValue(scope, out ris) || ris == null)
                {
                    ris = new RegionInfoForScope(region, expire);
                    InfobyScope[scope] = ris;
                }
                else
                {
                    ris.AddUpdate(region, expire);
                }

                return(true);
            }
            finally { Monitor.Exit(syncRoot); }
        }
Exemplo n.º 3
0
        public bool Contains(UUID scope, ulong handle)
        {
            if (!Monitor.TryEnter(syncRoot, MAX_LOCK_WAIT))
            {
                throw new ApplicationException("Lock could not be acquired after " + MAX_LOCK_WAIT + "ms");
            }

            try
            {
                RegionInfoForScope ris = null;
                if (!InfobyScope.TryGetValue(scope, out ris) || ris == null)
                {
                    return(false);
                }

                return(ris.Contains(handle));
            }
            finally { Monitor.Exit(syncRoot); }
        }
Exemplo n.º 4
0
        public bool TryGetValue(UUID scope, UUID id, out GridRegion value)
        {
            if (!Monitor.TryEnter(syncRoot, MAX_LOCK_WAIT))
            {
                throw new ApplicationException("Lock could not be acquired after " + MAX_LOCK_WAIT + "ms");
            }

            value = null;
            try
            {
                RegionInfoForScope ris = null;
                if (!InfobyScope.TryGetValue(scope, out ris) || ris == null)
                {
                    return(false);
                }
                value = ris.get(id);
            }
            finally { Monitor.Exit(syncRoot); }

            return(value != null);
        }