static void OnPlayerPlacedBlock(object sender, [NotNull] PlayerPlacedBlockEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } World world = e.Map.World; if (world != null && world.BlockDB.IsEnabled) { BlockDBEntry newEntry = new BlockDBEntry((int)DateTime.UtcNow.ToUnixTime(), e.Player.Info.ID, e.Coords, e.OldBlock, e.NewBlock, e.Context); world.BlockDB.AddEntry(newEntry); } }
CacheLinearResizeThreshold = 64 * 1024; // 1 MB (at 16 bytes/entry) void AddEntry(BlockDBEntry item) { lock ( SyncRoot ) { if (CacheSize == cacheStore.Length) { 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(); } else { // resize cache to fit EnsureCapacity(CacheSize + 1); } } cacheStore[CacheSize++] = item; } }
static void OnPlayerPlacedBlock( object sender, [NotNull] PlayerPlacedBlockEventArgs e ) { if( e == null ) throw new ArgumentNullException( "e" ); World world = e.Map.World; if( world != null && world.BlockDB.IsEnabled ) { BlockDBEntry newEntry = new BlockDBEntry( (int)DateTime.UtcNow.ToUnixTime(), e.Player.Info.ID, e.Coords, e.OldBlock, e.NewBlock, e.Context ); world.BlockDB.AddEntry( newEntry ); } }
void AddEntry( BlockDBEntry item ) { lock( SyncRoot ) { if( CacheSize == cacheStore.Length ) { 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(); } else { // resize cache to fit EnsureCapacity( CacheSize + 1 ); } } cacheStore[CacheSize++] = item; } }
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(); } }
public bool ProcessEntry( BlockDBEntry entry ) { if( inclusionSelector( entry ) ) { int index = map.Index( entry.X, entry.Y, entry.Z ); if( !excluded.Contains( index ) ) { if( exclusionSelector( entry ) ) { excluded.Add( index ); } else { result[index] = entry; } count++; if( count >= max ) { return false; } } } return true; }
public bool ProcessEntry( BlockDBEntry entry ) { if( selector( entry ) ) { int index = map.Index( entry.X, entry.Y, entry.Z ); if( !result.ContainsKey( index ) ) { result.Add( index, entry ); } count++; if( count >= max ) { return false; } } return true; }
public bool ProcessEntry( BlockDBEntry entry ) { if( selector( entry ) ) { int index = map.Index( entry.X, entry.Y, entry.Z ); result[index] = entry; count++; if( count >= max ) { return false; } } return true; }
public bool ProcessEntry( BlockDBEntry entry ) { if( selector( entry ) ) { result.Add( entry ); count++; if( count >= max ) { return false; } } return true; }