Skip to content

Commit

Permalink
updated count
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Austin committed Jul 16, 2018
1 parent 9c6cb13 commit 95476c3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Expand Up @@ -108,7 +108,7 @@ default <T> VanillaMethodWriterBuilder<T> methodWriterBuilder(@NotNull Class<T>
*/
Wire wire();

void batchAppend(final int time, final int size, BatchAppender batchAppender);
long batchAppend(final int time, final int size, BatchAppender batchAppender);


}
Expand Up @@ -202,7 +202,7 @@ public Wire wire() {
}

@Override
public void batchAppend(final int timeout, final int size, BatchAppender batchAppender) {
public long batchAppend(final int timeout, final int size, BatchAppender batchAppender) {

NativeBytesStore<Void> nbs = NativeBytesStore.nativeStoreWithFixedCapacity(size);
long startTime = System.nanoTime();
Expand Down Expand Up @@ -236,6 +236,7 @@ public void batchAppend(final int timeout, final int size, BatchAppender batchAp
}
}
} while (startTime + timeout * 1e9 > System.nanoTime());
return count;
}

@Nullable
Expand Down
Expand Up @@ -31,20 +31,20 @@ public static void main(String[] args) {
.build()) {

ExcerptAppender appender = q.acquireAppender();
appender.batchAppend(time, size, (address, canWrite, writeCount) -> {
count += appender.batchAppend(time, size, (address, canWrite, writeCount) -> {
long length = 0;

long count0 = 0;
// writeCount = writeCount == 1 ? 1 : ThreadLocalRandom.current().nextInt(writeCount-1)+1;
long fromAddress = nbs.addressForRead(0);
while (writeCount > count && length + 4 + size <= canWrite) {
UnsafeMemory.UNSAFE.copyMemory(fromAddress, address + 4, size);
UnsafeMemory.UNSAFE.putOrderedInt(null, address, size);
address += 4 + size;
length += 4 + size;
count++;
count0++;
}
// System.out.println("w "+count+" "+length);
return (count << 32) | length;
return (count0 << 32) | length;
});
}

Expand Down

0 comments on commit 95476c3

Please sign in to comment.