protected virtual void Dispose(bool disposing) { if (disposing) { _mReleaser.Dispose(); _mSemaphore.Dispose(); } }
public async Task Add(RowHolder item, ITransaction tran) { MixedPage currPage = null; for (ulong currPageId = this.lastPageId; currPageId != PageManagerConstants.NullPageId; currPageId = currPage.NextPageId()) { using Releaser lck = await tran.AcquireLock(currPageId, LockManager.LockTypeEnum.Shared).ConfigureAwait(false); currPage = await pageAllocator.GetMixedPage(currPageId, tran, this.columnTypes).ConfigureAwait(false); if (currPage.CanFit(item, tran)) { lck.Dispose(); using Releaser writeLock = await tran.AcquireLock(currPageId, LockManager.LockTypeEnum.Exclusive).ConfigureAwait(false); // Need to check can fit one more time. if (currPage.CanFit(item, tran)) { currPage.Insert(item, tran); return; } } } { using Releaser prevPageLck = await tran.AcquireLock(currPage.PageId(), LockManager.LockTypeEnum.Exclusive).ConfigureAwait(false); if (currPage.NextPageId() != PageManagerConstants.NullPageId) { // TODO: it would be good if caller had ability to control this lock. // This dispose doesn't mean anything in current implementation of read committed. prevPageLck.Dispose(); await Add(item, tran).ConfigureAwait(false); } else { currPage = await this.pageAllocator.AllocateMixedPage(this.columnTypes, currPage.PageId(), PageManagerConstants.NullPageId, tran).ConfigureAwait(false); using Releaser currPageLck = await tran.AcquireLock(currPage.PageId(), LockManager.LockTypeEnum.Exclusive).ConfigureAwait(false); this.lastPageId = currPage.PageId(); currPage.Insert(item, tran); } } }
public async Task <PagePointerOffsetPair> Add(char[] item, ITransaction tran) { StringOnlyPage currPage = null; int offset; for (ulong currPageId = this.lastPageId; currPageId != PageManagerConstants.NullPageId; currPageId = currPage.NextPageId()) { using Releaser lckReleaser = await tran.AcquireLock(currPageId, LockManager.LockTypeEnum.Shared).ConfigureAwait(false); currPage = await allocator.GetPageStr(currPageId, tran).ConfigureAwait(false); if (currPage.CanFit(item)) { lckReleaser.Dispose(); using Releaser writeLock = await tran.AcquireLock(currPageId, LockManager.LockTypeEnum.Exclusive).ConfigureAwait(false); // Need to check can fit one more time. if (currPage.CanFit(item)) { offset = currPage.Insert(item, tran); return(new PagePointerOffsetPair((long)currPage.PageId(), (int)offset)); } } } { using Releaser prevPage = await tran.AcquireLock(currPage.PageId(), LockManager.LockTypeEnum.Exclusive).ConfigureAwait(false); if (currPage.NextPageId() != PageManagerConstants.NullPageId) { prevPage.Dispose(); return(await Add(item, tran).ConfigureAwait(false)); } else { currPage = await this.allocator.AllocatePageStr(currPage.PageId(), PageManagerConstants.NullPageId, tran).ConfigureAwait(false); using Releaser lckReleaser = await tran.AcquireLock(currPage.PageId(), LockManager.LockTypeEnum.Exclusive).ConfigureAwait(false); offset = currPage.Insert(item, tran); this.lastPageId = currPage.PageId(); return(new PagePointerOffsetPair((long)currPage.PageId(), (int)offset)); } } }