aerc

Working clone of aerc-mail.org
git clone git://git.danielmoch.com/aerc.git
Log | Files | Refs | README | LICENSE

commit 305446abfd66e85fe2c46cb4a07a3abb9fa809a4
parent b5d5e0dbedee34bd5d3edf13616f055d4f227d36
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed, 10 Jan 2018 08:35:26 -0500

Sleep main and worker loops on idle

Diffstat:
Mcmd/aerc/main.go | 6++++++
Mworker/imap/worker.go | 3++-
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/cmd/aerc/main.go b/cmd/aerc/main.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "time" "git.sr.ht/~sircmpwn/aerc2/config" "git.sr.ht/~sircmpwn/aerc2/worker" @@ -28,10 +29,15 @@ func main() { workers = append(workers, work) } for { + activity := false for _, worker := range workers { if msg := worker.GetMessage(); msg != nil { + activity = true fmt.Printf("<- %T\n", msg) } } + if !activity { + time.Sleep(100 * time.Millisecond) + } } } diff --git a/worker/imap/worker.go b/worker/imap/worker.go @@ -4,6 +4,7 @@ import ( "git.sr.ht/~sircmpwn/aerc2/worker/types" "fmt" + "time" ) type IMAPWorker struct { @@ -52,7 +53,7 @@ func (w *IMAPWorker) Run() { fmt.Printf("<= %T\n", msg) w.handleMessage(msg) default: - // no-op + time.Sleep(100 * time.Millisecond) } } }