@Test public void shouldNotReceiveFromEmptyBuffer() { assertFalse(broadcastReceiver.receiveNext()); }
public boolean receiveNext() { boolean isAvailable = false; final AtomicBuffer buffer = this.buffer; final long tail = buffer.getLongVolatile(tailCounterIndex); long cursor = nextRecord; if (tail > cursor) { final int capacity = this.capacity; int recordOffset = (int)cursor & (capacity - 1); if (!validate(cursor, buffer, capacity)) { lappedCount.lazySet(lappedCount.get() + 1); cursor = buffer.getLongVolatile(latestCounterIndex); recordOffset = (int)cursor & (capacity - 1); } this.cursor = cursor; nextRecord = cursor + align(buffer.getInt(lengthOffset(recordOffset)), RECORD_ALIGNMENT); if (PADDING_MSG_TYPE_ID == buffer.getInt(typeOffset(recordOffset))) { recordOffset = 0; this.cursor = nextRecord; nextRecord += align(buffer.getInt(lengthOffset(recordOffset)), RECORD_ALIGNMENT); } this.recordOffset = recordOffset; isAvailable = true; } return isAvailable; }
BroadcastReceiver { public boolean receiveNext() { boolean isAvailable = false; final AtomicBuffer buffer = this.buffer; final long tail = buffer.getLongVolatile(tailCounterIndex); long cursor = nextRecord; if (tail > cursor) { final int capacity = this.capacity; int recordOffset = (int)cursor & (capacity - 1); if (!validate(cursor, buffer, capacity)) { lappedCount.lazySet(lappedCount.get() + 1); cursor = buffer.getLongVolatile(latestCounterIndex); recordOffset = (int)cursor & (capacity - 1); } this.cursor = cursor; nextRecord = cursor + align(buffer.getInt(lengthOffset(recordOffset)), RECORD_ALIGNMENT); if (PADDING_MSG_TYPE_ID == buffer.getInt(typeOffset(recordOffset))) { recordOffset = 0; this.cursor = nextRecord; nextRecord += align(buffer.getInt(lengthOffset(recordOffset)), RECORD_ALIGNMENT); } this.recordOffset = recordOffset; isAvailable = true; } return isAvailable; } }
BroadcastReceiver { public boolean receiveNext() { boolean isAvailable = false; final AtomicBuffer buffer = this.buffer; final long tail = buffer.getLongVolatile(tailCounterIndex); long cursor = nextRecord; if (tail > cursor) { final int capacity = this.capacity; int recordOffset = (int)cursor & (capacity - 1); if (!validate(cursor, buffer, capacity)) { lappedCount.lazySet(lappedCount.get() + 1); cursor = buffer.getLongVolatile(latestCounterIndex); recordOffset = (int)cursor & (capacity - 1); } this.cursor = cursor; nextRecord = cursor + align(buffer.getInt(lengthOffset(recordOffset)), RECORD_ALIGNMENT); if (PADDING_MSG_TYPE_ID == buffer.getInt(typeOffset(recordOffset))) { recordOffset = 0; this.cursor = nextRecord; nextRecord += align(buffer.getInt(lengthOffset(recordOffset)), RECORD_ALIGNMENT); } this.recordOffset = recordOffset; isAvailable = true; } return isAvailable; } BroadcastReceiver(final AtomicBuffer buffer); }
BroadcastReceiver { public boolean receiveNext() { boolean isAvailable = false; final AtomicBuffer buffer = this.buffer; final long tail = buffer.getLongVolatile(tailCounterIndex); long cursor = nextRecord; if (tail > cursor) { final int capacity = this.capacity; int recordOffset = (int)cursor & (capacity - 1); if (!validate(cursor, buffer, capacity)) { lappedCount.lazySet(lappedCount.get() + 1); cursor = buffer.getLongVolatile(latestCounterIndex); recordOffset = (int)cursor & (capacity - 1); } this.cursor = cursor; nextRecord = cursor + align(buffer.getInt(lengthOffset(recordOffset)), RECORD_ALIGNMENT); if (PADDING_MSG_TYPE_ID == buffer.getInt(typeOffset(recordOffset))) { recordOffset = 0; this.cursor = nextRecord; nextRecord += align(buffer.getInt(lengthOffset(recordOffset)), RECORD_ALIGNMENT); } this.recordOffset = recordOffset; isAvailable = true; } return isAvailable; } BroadcastReceiver(final AtomicBuffer buffer); int capacity(); long lappedCount(); int typeId(); int offset(); int length(); MutableDirectBuffer buffer(); boolean receiveNext(); boolean validate(); }
BroadcastReceiver { public boolean receiveNext() { boolean isAvailable = false; final AtomicBuffer buffer = this.buffer; final long tail = buffer.getLongVolatile(tailCounterIndex); long cursor = nextRecord; if (tail > cursor) { final int capacity = this.capacity; int recordOffset = (int)cursor & (capacity - 1); if (!validate(cursor, buffer, capacity)) { lappedCount.lazySet(lappedCount.get() + 1); cursor = buffer.getLongVolatile(latestCounterIndex); recordOffset = (int)cursor & (capacity - 1); } this.cursor = cursor; nextRecord = cursor + align(buffer.getInt(lengthOffset(recordOffset)), RECORD_ALIGNMENT); if (PADDING_MSG_TYPE_ID == buffer.getInt(typeOffset(recordOffset))) { recordOffset = 0; this.cursor = nextRecord; nextRecord += align(buffer.getInt(lengthOffset(recordOffset)), RECORD_ALIGNMENT); } this.recordOffset = recordOffset; isAvailable = true; } return isAvailable; } BroadcastReceiver(final AtomicBuffer buffer); int capacity(); long lappedCount(); int typeId(); int offset(); int length(); MutableDirectBuffer buffer(); boolean receiveNext(); boolean validate();  }