use of org.apache.jackrabbit.oak.plugins.document.persistentCache.broadcast.Broadcaster in project jackrabbit-oak by apache.
the class PersistentCache method broadcast.
void broadcast(CacheType type, Function<WriteBuffer, Void> writer) {
Broadcaster b = broadcaster;
if (b == null) {
return;
}
WriteBuffer buff = writeBuffer.get();
if (buff == null) {
buff = new WriteBuffer();
writeBuffer.set(buff);
}
buff.clear();
// space for the length
buff.putInt(0);
buff.put(broadcastId);
buff.put((byte) type.ordinal());
writer.apply(buff);
ByteBuffer byteBuff = buff.getBuffer();
int length = byteBuff.position();
byteBuff.limit(length);
// write length
byteBuff.putInt(0, length);
byteBuff.position(0);
b.send(byteBuff);
}
Aggregations