From f7c0f75275d0fde2d8b7614f1501f0ad0cd3a01c Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Tue, 3 Mar 2015 13:39:37 -0800 Subject: logd: replace internal CLOCK_MONOTONIC use with sequence numbers - switch to simpler and faster internal sequence number, drops a syscall overhead on 32-bit platforms. - add ability to break-out of flushTo loop with filter return -1 allowing in reduction in reader overhead. Change-Id: Ic5cb2b9afa4d9470153971fc9197b07279e2b79d --- logd/LogBufferElement.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'logd/LogBufferElement.h') diff --git a/logd/LogBufferElement.h b/logd/LogBufferElement.h index fdca973..25f1450 100644 --- a/logd/LogBufferElement.h +++ b/logd/LogBufferElement.h @@ -18,6 +18,7 @@ #define _LOGD_LOG_BUFFER_ELEMENT_H__ #include +#include #include #include #include @@ -29,8 +30,9 @@ class LogBufferElement { const pid_t mTid; char *mMsg; const unsigned short mMsgLen; - const log_time mMonotonicTime; + const uint64_t mSequence; const log_time mRealTime; + static atomic_int_fast64_t sequence; public: LogBufferElement(log_id_t log_id, log_time realtime, @@ -43,11 +45,12 @@ public: pid_t getPid(void) const { return mPid; } pid_t getTid(void) const { return mTid; } unsigned short getMsgLen() const { return mMsgLen; } - log_time getMonotonicTime(void) const { return mMonotonicTime; } + uint64_t getSequence(void) const { return mSequence; } + static uint64_t getCurrentSequence(void) { return sequence.load(memory_order_relaxed); } log_time getRealTime(void) const { return mRealTime; } - static const log_time FLUSH_ERROR; - log_time flushTo(SocketClient *writer); + static const uint64_t FLUSH_ERROR; + uint64_t flushTo(SocketClient *writer); }; #endif -- cgit v1.1