fCraft.BlockDB.AddEntry C# (CSharp) Method

AddEntry() private method

private AddEntry ( BlockDBEntry item ) : void
item BlockDBEntry
return void
        private void AddEntry( BlockDBEntry item )
        {
            try {
                locker.EnterUpgradeableReadLock();
                if ( CacheSize == cacheStore.Length ) {
                    using ( locker.WriteLock() ) {
                        if ( !isPreloaded && CacheSize >= CacheLinearResizeThreshold ) {
                            // Avoid bloating the cacheStore if we are not preloaded.
                            // This might cause lag spikes, since it's ran from main scheduler thread.
                            Flush( false );
                        } else {
                            // resize cache to fit
                            EnsureCapacity( CacheSize + 1 );
                        }
                    }
                }
                cacheStore[CacheSize++] = item;
            } finally {
                locker.ExitUpgradeableReadLock();
            }
        }