Java Code Examples for net.openhft.chronicle.bytes.Bytes#addressForWrite()

The following examples show how to use net.openhft.chronicle.bytes.Bytes#addressForWrite() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Ed25519.java    From Chronicle-Salt with Apache License 2.0 5 votes vote down vote up
void sign(Bytes<?> sigAndMsg, BytesStore<?, ?> message, BytesStore<?, ?> secretKey) {
    int msgLen = Math.toIntExact(message.readRemaining());
    long signature = sigAndMsg.addressForWrite(sigAndMsg.writePosition());
    long messageAddress = message.addressForRead(message.readPosition());
    long secretKeyAddress = secretKey.addressForRead(secretKey.readPosition());
    checkValid(SODIUM.crypto_sign_ed25519(signature, sigLen, messageAddress, msgLen, secretKeyAddress), "Unable to sign");
    long bytesToSkip = sigLen.longValue();
    sigAndMsg.writeSkip(bytesToSkip);
}
 
Example 2
Source File: BenchmarkMain.java    From Chronicle-Queue with Apache License 2.0 5 votes vote down vote up
private static void writeMessage(Wire wire, int messageSize) {
    Bytes<?> bytes = wire.bytes();
    long wp = bytes.writePosition();
    long addr = bytes.addressForWrite(wp);
    Memory memory = OS.memory();
    for (int i = 0; i < messageSize; i += 16) {
        memory.writeLong(addr + i, 0L);
        memory.writeLong(addr + i + 8, 0L);
    }

    bytes.writeSkip(messageSize);
    bytes.writeLong(wp, System.nanoTime());
}
 
Example 3
Source File: ThroughputMain.java    From Chronicle-Queue with Apache License 2.0 5 votes vote down vote up
static void addToEndOfCache(Wire wire2) {
    Bytes<?> bytes = wire2.bytes();
    long addr = bytes.addressForWrite(bytes.writePosition());
    int pad = (int) (64 - (addr & 63));
    if (pad < 64)
        wire2.addPadding(pad);
}