Java Code Examples for net.openhft.chronicle.wire.DocumentContext#close()

The following examples show how to use net.openhft.chronicle.wire.DocumentContext#close() . 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: GarbageFreeMethodPublisher.java    From Chronicle-Queue with Apache License 2.0 5 votes vote down vote up
@Override
    public void onEightyByteMessage(final EightyByteMessage message) {

        final ExcerptAppender appender = outputSupplier.get();
//        DebugTimestamps.operationStart(DebugTimestamps.Operation.GET_WRITING_DOCUMENT);
        @NotNull DocumentContext context = appender.writingDocument();
//        DebugTimestamps.operationEnd(DebugTimestamps.Operation.GET_WRITING_DOCUMENT);
        try {
            Wire wire = context.wire();
            // log write
//            DebugTimestamps.operationStart(DebugTimestamps.Operation.WRITE_EVENT);
            try {
                wire.write(MethodReader.HISTORY).marshallable(MessageHistory.get());
                final ValueOut valueOut = wire.writeEventName("onEightyByteMessage");
                valueOut.object(EightyByteMessage.class, message);
                wire.padToCacheAlign();
            } finally {
//                DebugTimestamps.operationEnd(DebugTimestamps.Operation.WRITE_EVENT);
            }
        } finally {

//            DebugTimestamps.operationStart(DebugTimestamps.Operation.CLOSE_CONTEXT);
            try {
                context.close();
            } finally {
//                DebugTimestamps.operationEnd(DebugTimestamps.Operation.CLOSE_CONTEXT);
            }
        }
    }
 
Example 2
Source File: TailerDirectionTest.java    From Chronicle-Queue with Apache License 2.0 5 votes vote down vote up
/**
 * Add a test message with the given ExcerptAppender and return the index position of the entry
 *
 * @param appender ExceptAppender
 * @param msg      test message
 * @return index position of the entry
 */
private long appendEntry(@NotNull final ExcerptAppender appender, String msg) {
    DocumentContext dc = appender.writingDocument();
    try {
        dc.wire().write().text(msg);
        return dc.index();
    } finally {
        dc.close();
    }
}