in activeio-core/src/main/java/org/apache/activeio/journal/active/JournalImpl.java [206:241]
private BatchedWrite addToPendingWriteBatch(Record record, Location mark, boolean force) throws InterruptedException {
// Load the write batch up with data from our record.
// it may take more than one write batch if the record is large.
BatchedWrite answer = null;
while (record.hasRemaining()) {
// Do we need another BatchWrite?
boolean queueTheWrite=false;
if (pendingBatchWrite == null) {
pendingBatchWrite = new BatchedWrite(packetPool.getPacket());
queueTheWrite = true;
}
answer = pendingBatchWrite;
// Can we continue to use the pendingBatchWrite?
boolean full = !pendingBatchWrite.append(record, mark, force);
if( queueTheWrite ) {
final BatchedWrite queuedWrite = pendingBatchWrite;
executor.execute(new Runnable() {
public void run() {
try {
queuedWrite(queuedWrite);
} catch (InterruptedException e) {
}
}
});
}
if( full )
pendingBatchWrite = null;
}
return answer;
}