private void logMessage0( final Disruptor<RingBufferLogEvent> theDisruptor, final String fqcn, final Level level, final Marker marker, final Message message, final Throwable thrown) { final Info info = Info.THREADLOCAL.get(); logMessageInAppropriateThread(info, theDisruptor, fqcn, level, marker, message, thrown); }
public static void stop() { final Disruptor<RingBufferLogEvent> temp = disruptor; // Must guarantee that publishing to the RingBuffer has stopped // before we call disruptor.shutdown() disruptor = null; // client code fails with NPE if log after stop = OK if (temp == null) { return; // stop() has already been called } // Calling Disruptor.shutdown() will wait until all enqueued events are fully processed, // but this waiting happens in a busy-spin. To avoid (postpone) wasting CPU, // we sleep in short chunks, up to 10 seconds, waiting for the ringbuffer to drain. for (int i = 0; hasBacklog(temp) && i < MAX_DRAIN_ATTEMPTS_BEFORE_SHUTDOWN; i++) { try { Thread.sleep(SLEEP_MILLIS_BETWEEN_DRAIN_ATTEMPTS); // give up the CPU for a while } catch (final InterruptedException e) { // ignored } } temp.shutdown(); // busy-spins until all events currently in the disruptor have been processed EXECUTOR.shutdown(); // finally, kill the processor thread Info.THREADLOCAL.remove(); // LOG4J2-323 }