From b652c48bd443c8f3eb9ba761467250406ab0c0f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Tue, 8 Sep 2020 15:41:31 +0200 Subject: [PATCH] Simplify stop logic (closing a RO fd is not worth the added complexity) --- afterlock/afterlock.go | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/afterlock/afterlock.go b/afterlock/afterlock.go index 001cace..f62471d 100644 --- a/afterlock/afterlock.go +++ b/afterlock/afterlock.go @@ -2,7 +2,6 @@ package afterlock import( "time" - "sync" "errors" ) @@ -28,8 +27,6 @@ type AfterLock struct { InitialDelay uint LoopDelay uint keyboardDeviceNode string - wg sync.WaitGroup - stopFlag *AtomicFlag keypressFlag *AtomicFlag Display Display LockScreen Lockscreen @@ -40,7 +37,6 @@ type AfterLock struct { func New(keyboardDeviceNode string) *AfterLock { return &AfterLock{ keyboardDeviceNode: keyboardDeviceNode, - stopFlag: NewAtomicFlag(false), keypressFlag: NewAtomicFlag(false), } } @@ -52,7 +48,6 @@ func New(keyboardDeviceNode string) *AfterLock { func (af *AfterLock) Start() { af.checkStructConfigured() - af.wg.Add(1) go af.detectKeypresses() time.Sleep(time.Duration(af.InitialDelay) * time.Second) @@ -83,10 +78,6 @@ func (af *AfterLock) detectKeypresses() { if err != nil { panic(err) } - if af.stopFlag.Get() { - af.wg.Done() - return - } af.keypressFlag.Set(true) } } @@ -98,8 +89,6 @@ func (af *AfterLock) hybernateDisplayLoop() { panic(err) } if !screenLocked { - af.stopFlag.Set(true) - af.wg.Wait() return }