/** * Release for write the old fragment read which are pending release. eg not previously released * @param pipe Pipe target */ public static <S extends MessageSchema<S>> void releasePendingReadLock(Pipe<S> pipe) { assert(Pipe.singleThreadPerPipeRead(pipe.id)); PendingReleaseData.releasePendingReadRelease(pipe.pendingReleases, pipe); }
/** * Release for write the old fragments which total up to the provided consumed number of bytes. * @param pipe Pipe target * @param consumed int bytes consumed so far allowing these fragments to be released. */ public static <S extends MessageSchema<S>> void releasePendingAsReadLock(Pipe<S> pipe, int consumed) { assert(Pipe.singleThreadPerPipeRead(pipe.id)); PendingReleaseData.releasePendingAsReadRelease(pipe.pendingReleases, pipe, consumed); }
/** * Release all pending fragments for release * @param pipe */ public static <S extends MessageSchema<S>> void releaseAllPendingReadLock(Pipe<S> pipe) { assert(Pipe.singleThreadPerPipeRead(pipe.id)); PendingReleaseData.releaseAllPendingReadRelease(pipe.pendingReleases, pipe); }
/** * Release for write the old fragments which total up to the provided consumed number of bytes. * @param pipe Pipe target * @param consumed int bytes consumed so far allowing these fragments to be released. */ public static <S extends MessageSchema<S>> void releasePendingAsReadLock(Pipe<S> pipe, int consumed) { assert(Pipe.singleThreadPerPipeRead(pipe.id)); PendingReleaseData.releasePendingAsReadRelease(pipe.pendingReleases, pipe, consumed); }
/** * Release for write the old fragment read which are pending release. eg not previously released * @param pipe Pipe target */ public static <S extends MessageSchema<S>> void releasePendingReadLock(Pipe<S> pipe) { assert(Pipe.singleThreadPerPipeRead(pipe.id)); PendingReleaseData.releasePendingReadRelease(pipe.pendingReleases, pipe); }
/** * Release all pending fragments for release * @param pipe */ public static <S extends MessageSchema<S>> void releaseAllPendingReadLock(Pipe<S> pipe) { assert(Pipe.singleThreadPerPipeRead(pipe.id)); PendingReleaseData.releaseAllPendingReadRelease(pipe.pendingReleases, pipe); }
/** * Low level API only for checking if there is content to read of the size provided. * @param pipe Pipe source * @param size int message size looking for * @return boolean true if there is content */ public static <S extends MessageSchema<S>> boolean hasContentToRead(Pipe<S> pipe, int size) { //do not use with high level API, is dependent on low level confirm calls. assert(Pipe.singleThreadPerPipeRead(pipe.id)); //optimized for the other method without size. this is why the -1 is there and we use > for target comparison. return contentToLowLevelRead2(pipe, pipe.llWrite.llrConfirmedPosition+size-1, pipe.llWrite); }
/** * Release for write the old fragments which total up to the provided consumed number of bytes. * @param pipe Pipe target * @param consumed int bytes consumed so far allowing these fragments to be released. */ public static <S extends MessageSchema<S>> void releasePendingAsReadLock(Pipe<S> pipe, int consumed) { assert(Pipe.singleThreadPerPipeRead(pipe.id)); PendingReleaseData.releasePendingAsReadRelease(pipe.pendingReleases, pipe, consumed); }
/** * Release all pending fragments for release * @param pipe */ public static <S extends MessageSchema<S>> void releaseAllPendingReadLock(Pipe<S> pipe) { assert(Pipe.singleThreadPerPipeRead(pipe.id)); PendingReleaseData.releaseAllPendingReadRelease(pipe.pendingReleases, pipe); }
/** * Low level API only for checking if there is content to read of the size provided. * @param pipe Pipe source * @param size int message size looking for * @return boolean true if there is content */ public static <S extends MessageSchema<S>> boolean hasContentToRead(Pipe<S> pipe, int size) { //do not use with high level API, is dependent on low level confirm calls. assert(Pipe.singleThreadPerPipeRead(pipe.id)); //optimized for the other method without size. this is why the -1 is there and we use > for target comparison. return contentToLowLevelRead2(pipe, pipe.llWrite.llrConfirmedPosition+size-1, pipe.llWrite); }
/** * Low level API only for checking if there is content to read of the size provided. * @param pipe Pipe source * @param size int message size looking for * @return boolean true if there is content */ public static <S extends MessageSchema<S>> boolean hasContentToRead(Pipe<S> pipe, int size) { //do not use with high level API, is dependent on low level confirm calls. assert(Pipe.singleThreadPerPipeRead(pipe.id)); //optimized for the other method without size. this is why the -1 is there and we use > for target comparison. return contentToLowLevelRead2(pipe, pipe.llWrite.llrConfirmedPosition+size-1, pipe.llWrite); }
/** * Release any reads that were held back due to batching. * @param pipe Pipe to be examined */ public static <S extends MessageSchema<S>> void releaseAllBatchedReads(Pipe<S> pipe) { assert(Pipe.singleThreadPerPipeRead(pipe.id)); if (pipe.lastReleasedSlabTail > pipe.slabRingTail.tailPos.get()) { PaddedInt.set(pipe.blobRingTail.bytesTailPos,pipe.lastReleasedBlobTail); pipe.slabRingTail.tailPos.lazySet(pipe.lastReleasedSlabTail); pipe.batchReleaseCountDown = pipe.batchReleaseCountDownInit; } }
/** * Release all batched read releases up to the passed in position. * @param pipe Pipe target * @param newTailToPublish long new tail * @param newTailBytesToPublish int new bytes total */ public static <S extends MessageSchema<S>> void releaseBatchedReadReleasesUpToPosition(Pipe<S> pipe, long newTailToPublish, int newTailBytesToPublish) { assert(Pipe.singleThreadPerPipeRead(pipe.id)); assert(newTailToPublish<=pipe.lastReleasedSlabTail) : "This new value is forward of the next Release call, eg its too large"; assert(newTailToPublish>=pipe.slabRingTail.tailPos.get()) : "This new value is behind the existing published Tail, eg its too small "; PaddedInt.set(pipe.blobRingTail.bytesTailPos, newTailBytesToPublish); pipe.slabRingTail.tailPos.lazySet(newTailToPublish); pipe.batchReleaseCountDown = pipe.batchReleaseCountDownInit; }
/** * Checks pipe to see if message equals expected * @param pipe to be checked * @param expected used for comparison with message * @return <code>true</code> if message == expected, else <code>false</code> */ public static boolean peekMsg(Pipe pipe, int expected) { assert(Pipe.singleThreadPerPipeRead(pipe.id)); return StackStateWalker.hasContentToRead(pipe) && (expected == Pipe.readValue(Pipe.slab(pipe),pipe.slabMask,pipe.ringWalker.nextWorkingTail)); }
/** * Release all batched read releases up to the current position. Eg all things read can now be written over. * @param pipe Pipe target */ public static <S extends MessageSchema<S>> void releaseBatchedReadReleasesUpToThisPosition(Pipe<S> pipe) { assert(Pipe.singleThreadPerPipeRead(pipe.id)); releaseBatchedReadReleasesUpToPosition(pipe, Pipe.getWorkingTailPosition(pipe), Pipe.getWorkingBlobTailPosition(pipe)); }
/** * Checks pipe to see if message equals expected * @param pipe to be checked * @param expected used for comparison with message * @return <code>true</code> if message == expected, else <code>false</code> */ public static boolean peekMsg(Pipe pipe, int expected) { assert(Pipe.singleThreadPerPipeRead(pipe.id)); return StackStateWalker.hasContentToRead(pipe) && (expected == Pipe.readValue(Pipe.slab(pipe),pipe.slabMask,pipe.ringWalker.nextWorkingTail)); }
/** * Checks pipe to see if message equals expected * @param pipe to be checked * @param expected used for comparison with message * @return <code>true</code> if message == expected, else <code>false</code> */ public static boolean peekMsg(Pipe pipe, int expected) { assert(Pipe.singleThreadPerPipeRead(pipe.id)); return StackStateWalker.hasContentToRead(pipe) && (expected == Pipe.readValue(Pipe.slab(pipe),pipe.slabMask,pipe.ringWalker.nextWorkingTail)); }
/** * Release all batched read releases up to the current position. Eg all things read can now be written over. * @param pipe Pipe target */ public static <S extends MessageSchema<S>> void releaseBatchedReadReleasesUpToThisPosition(Pipe<S> pipe) { assert(Pipe.singleThreadPerPipeRead(pipe.id)); releaseBatchedReadReleasesUpToPosition(pipe, Pipe.getWorkingTailPosition(pipe), Pipe.getWorkingBlobTailPosition(pipe)); }
static <S extends MessageSchema<S>> void releaseBatchedReads(Pipe<S> pipe, int workingBlobRingTailPosition, long nextWorkingTail) { assert(Pipe.singleThreadPerPipeRead(pipe.id)); if (decBatchRelease(pipe)<=0) { setBlobTailPosition(pipe,workingBlobRingTailPosition); //NOTE: the working tail is in use as part of the read and should not be modified // this method only modifies the externally visible tail to let writers see it. pipe.slabRingTail.tailPos.lazySet(nextWorkingTail); beginNewReleaseBatch(pipe); assert(validateInsideData(pipe, pipe.blobReadBase)); } else { storeUnpublishedTail(pipe, nextWorkingTail, workingBlobRingTailPosition); } }
static <S extends MessageSchema<S>> void releaseBatchedReads(Pipe<S> pipe, int workingBlobRingTailPosition, long nextWorkingTail) { assert(Pipe.singleThreadPerPipeRead(pipe.id)); if (decBatchRelease(pipe)<=0) { setBlobTailPosition(pipe,workingBlobRingTailPosition); //NOTE: the working tail is in use as part of the read and should not be modified // this method only modifies the externally visible tail to let writers see it. pipe.slabRingTail.tailPos.lazySet(nextWorkingTail); beginNewReleaseBatch(pipe); assert(validateInsideData(pipe, pipe.blobReadBase)); } else { storeUnpublishedTail(pipe, nextWorkingTail, workingBlobRingTailPosition); } }