internal void FreeChunk(PoolChunk <T> chunk, long handle, SizeClass sizeClass) { bool mustDestroyChunk; lock (this) { switch (sizeClass) { case Buffers.SizeClass.Normal: ++this.NumNormalDeallocations; break; case Buffers.SizeClass.Small: ++this.NumSmallDeallocations; break; case Buffers.SizeClass.Tiny: ++this.NumTinyDeallocations; break; default: throw new ArgumentOutOfRangeException(); } mustDestroyChunk = !chunk.Parent.Free(chunk, handle); } if (mustDestroyChunk) { // destroyChunk not need to be called while holding the synchronized lock. this.DestroyChunk(chunk); } }
internal void FreeChunk(PoolChunk <T> chunk, long handle, SizeClass sizeClass, bool finalizer) { bool destroyChunk; lock (this) { if (!finalizer) { switch (sizeClass) { case Buffers.SizeClass.Normal: ++_deallocationsNormal; break; case Buffers.SizeClass.Small: ++_deallocationsSmall; break; case Buffers.SizeClass.Tiny: ++_deallocationsTiny; break; default: ThrowHelper.ThrowArgumentOutOfRangeException(); break; } } destroyChunk = !chunk.Parent.Free(chunk, handle); } if (destroyChunk) { // destroyChunk not need to be called while holding the synchronized lock. DestroyChunk(chunk); } }
internal void Free(PoolChunk <T> chunk, long handle, int normCapacity, PoolThreadCache <T> cache) { if (chunk.Unpooled) { int size = chunk.ChunkSize; DestroyChunk(chunk); switch (chunk.Origin) { case PoolChunk <T> .PoolChunkOrigin.UnpooledNormal: Interlocked.Decrement(ref this.deallocationsNormal); break; case PoolChunk <T> .PoolChunkOrigin.UnpooledHuge: Interlocked.Add(ref this.activeBytesHuge, -size); Interlocked.Decrement(ref this.deallocationsHuge); break; default: throw new InvalidOperationException("Unsupported PoolChunk.Origin: " + chunk.Origin); } } else { SizeClass sc = this.SizeClass(normCapacity); if (cache != null && cache.Add(this, chunk, handle, normCapacity, sc)) { // cached so not free it. return; } this.FreeChunk(chunk, handle, sc); } }
private void InsUpdDelSize(char Event, int id) { var msg = ""; if (Event == 'I' || Event == 'U') { var objSize = new SizeClass(id, txtSize.Text); msg = BL_Size.InsUpdDelSize(Event, objSize, out id); } else { var objSize = new SizeClass(id, ""); msg = BL_Size.InsUpdDelSize(Event, objSize, out id); } if (DatabaseMessage.ContainMessage(msg)) { _msgbox.ShowSuccess(msg); } else { _msgbox.ShowWarning(msg); } FillGridview(); ClearAll(); }
public static List <SizeClass> GetSize(int Event, int id, string code, string code1) { var lst = new List <SizeClass>(); var dt = DlSize.GetSize(Event, id, code, code1); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { var obj = new SizeClass(Convert.ToInt32(dr["Id"]), dr["Size"].ToString()); lst.Add(obj); } } return(lst); }
static MemoryRegionCache[] CreateSubPageCaches( int cacheSize, int numCaches, SizeClass sizeClass) { if (cacheSize > 0) { var cache = new MemoryRegionCache[numCaches]; for (int i = 0; i < cache.Length; i++) { cache[i] = new SubPageMemoryRegionCache(cacheSize, sizeClass); } return(cache); } else { return(null); } }
MemoryRegionCache Cache(PoolArena <T> area, int normCapacity, SizeClass sizeClass) { switch (sizeClass) { case SizeClass.Normal: return(CacheForNormal(area, normCapacity)); case SizeClass.Small: return(CacheForSmall(area, normCapacity)); case SizeClass.Tiny: return(CacheForTiny(area, normCapacity)); default: ThrowHelper.ThrowArgumentOutOfRangeException(); return(default); } }
MemoryRegionCache Cache(int normCapacity, SizeClass sizeClass) { switch (sizeClass) { case SizeClass.Normal: return(this.CacheForNormal(normCapacity)); case SizeClass.Small: return(this.CacheForSmall(normCapacity)); case SizeClass.Tiny: return(this.CacheForTiny(normCapacity)); default: throw new ArgumentOutOfRangeException($"Unknown class {sizeClass}"); } }
internal void Free(PoolChunk <T> chunk, long handle, int normCapacity, PoolThreadCache <T> cache) { if (chunk.Unpooled) { int size = chunk.ChunkSize; this.DestroyChunk(chunk); Interlocked.Add(ref this.activeBytesHuge, -size); Interlocked.Decrement(ref this.deallocationsHuge); } else { SizeClass sc = this.SizeClass(normCapacity); if (cache != null && cache.Add(this, chunk, handle, normCapacity, sc)) { // cached so not free it. return; } this.FreeChunk(chunk, handle, sc); } }
internal void Free(PoolChunk <T> chunk, long handle, int normCapacity, PoolThreadCache <T> cache) { if (chunk.Unpooled) { int size = chunk.ChunkSize; DestroyChunk(chunk); _ = Interlocked.Add(ref _activeBytesHuge, -size); _ = Interlocked.Increment(ref _deallocationsHuge); } else { SizeClass sizeClass = SizeClass(normCapacity); if (cache is object && cache.Add(this, chunk, handle, normCapacity, sizeClass)) { // cached so not free it. return; } FreeChunk(chunk, handle, sizeClass, false); } }
public static string InsUpdDelSize(char Event, SizeClass obj, out int returnId) { returnId = 0; try { var cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "USP_IUD_tbl_Size_Setup"; cmd.Connection = DL_CCommon.ConnectionForCommonDb(); cmd.Parameters.AddWithValue("@EVENT", Event); cmd.Parameters.AddWithValue("@ID", obj.Id); cmd.Parameters.AddWithValue("@Size", obj.Size); var outparameter = new SqlParameter("@MSG", SqlDbType.NVarChar, 200) { Direction = ParameterDirection.Output }; cmd.Parameters.Add(outparameter); var outId = new SqlParameter("@RETURNOUTID", SqlDbType.NVarChar, 100) { Direction = ParameterDirection.Output }; cmd.Parameters.Add(outId); cmd.ExecuteNonQuery(); var msg = cmd.Parameters[outparameter.ParameterName].Value; returnId = Convert.ToInt32(cmd.Parameters[outId.ParameterName].Value); return(Convert.ToString(msg)); } catch (Exception ex) { throw new ArgumentException(ex.Message); } finally { DL_CCommon.ConnectionForCommonDb().Close(); } }
protected MemoryRegionCache(int size, SizeClass sizeClass) { _size = MathUtil.SafeFindNextPositivePowerOfTwo(size); _queue = PlatformDependent.NewFixedMpscQueue <Entry>(_size); _sizeClass = sizeClass; }
/* Collisions */ public void setSizeClass(SizeClass newSize) { size = newSize; mass = masses [(int)size]; }
internal SubPageMemoryRegionCache(int size, SizeClass sizeClass) : base(size, sizeClass) { }
/// <summary> /// Add <see cref="PoolChunk{T}"/> and <paramref name="handle"/> to the cache if there is enough room. /// </summary> /// <returns><c>true</c> if it fit into the cache <c>false</c> otherwise.</returns> internal bool Add(PoolArena <T> area, PoolChunk <T> chunk, long handle, int normCapacity, SizeClass sizeClass) { MemoryRegionCache cache = Cache(area, normCapacity, sizeClass); if (cache is null) { return(false); } return(cache.Add(chunk, handle)); }
protected MemoryRegionCache(int size, SizeClass sizeClass) { this.size = IntegerExtensions.RoundUpToPowerOfTwo(size); this.queue = new MpscArrayQueue <Entry>(this.size); this.sizeClass = sizeClass; }
/// // Add {@link PoolChunk} and {@code handle} to the cache if there is enough room. // Returns {@code true} if it fit into the cache {@code false} otherwise. // internal bool Add(PoolArena <T> area, PoolChunk <T> chunk, long handle, int normCapacity, SizeClass sizeClass) { MemoryRegionCache c = this.Cache(normCapacity, sizeClass); return(c != null && c.Add(chunk, handle)); }
protected MemoryRegionCache(int size, SizeClass sizeClass) { this.size = IntegerExtensions.RoundUpToPowerOfTwo(size); this.queue = PlatformDependent.NewFixedMpscQueue <Entry>(this.size); this.sizeClass = sizeClass; }
public static string InsUpdDelSize(char Event, SizeClass obj, out int id) { id = 0; return(DlSize.InsUpdDelSize(Event, obj, out id)); }