From 487c8fe88f4cfcc55850b8aef73665b1d09b8fe0 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 16 Aug 2017 03:24:23 +0900 Subject: Make Reader event notification asynchronous Instead of notifying the event coordinator (EventBox) whenever a new line is arrived, start a background goroutine that periodically does the task. Atomic.StoreInt32 is much cheaper than mutex synchronization that happens during EventBox update. --- src/constants.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/constants.go') diff --git a/src/constants.go b/src/constants.go index 10df1e7e..0f6a32c9 100644 --- a/src/constants.go +++ b/src/constants.go @@ -16,7 +16,10 @@ const ( coordinatorDelayStep time.Duration = 10 * time.Millisecond // Reader - readerBufferSize = 64 * 1024 + readerBufferSize = 64 * 1024 + readerPollIntervalMin = 10 * time.Millisecond + readerPollIntervalStep = 5 * time.Millisecond + readerPollIntervalMax = 50 * time.Millisecond // Terminal initialDelay = 20 * time.Millisecond @@ -68,7 +71,7 @@ const ( EvtSearchProgress EvtSearchFin EvtHeader - EvtClose + EvtReady ) const ( -- cgit v1.2.3