diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-06-02 13:20:02 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-06-02 13:20:02 -0400 |
commit | a81467dda9d577be706a1875451a3b031840639d (patch) | |
tree | dce38c7c37523ab247f91533ec7c178c1a95da0f /worker/types/worker.go | |
parent | 7d1770754ff432b0c6f153c066e4c749683b563f (diff) | |
download | aerc-a81467dda9d577be706a1875451a3b031840639d.tar.gz |
Remove worker callbacks when Done is received
Diffstat (limited to 'worker/types/worker.go')
-rw-r--r-- | worker/types/worker.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/worker/types/worker.go b/worker/types/worker.go index 38140e0..85c19f1 100644 --- a/worker/types/worker.go +++ b/worker/types/worker.go @@ -72,13 +72,17 @@ func (worker *Worker) PostMessage(msg WorkerMessage, func (worker *Worker) ProcessMessage(msg WorkerMessage) WorkerMessage { if resp := msg.InResponseTo(); resp != nil { - worker.Logger.Printf("(ui)<= %T:%T\n", msg, resp) + worker.Logger.Printf("(ui)<= %T(%d):%T(%d)\n", + msg, msg.getId(), resp, resp.getId()) } else { - worker.Logger.Printf("(ui)<= %T\n", msg) + worker.Logger.Printf("(ui)<= %T(%d)\n", msg, msg.getId()) } if inResponseTo := msg.InResponseTo(); inResponseTo != nil { if f, ok := worker.actionCallbacks[inResponseTo.getId()]; ok { f(msg) + if _, ok := msg.(*Done); ok { + delete(worker.actionCallbacks, inResponseTo.getId()) + } } } return msg @@ -86,13 +90,17 @@ func (worker *Worker) ProcessMessage(msg WorkerMessage) WorkerMessage { func (worker *Worker) ProcessAction(msg WorkerMessage) WorkerMessage { if resp := msg.InResponseTo(); resp != nil { - worker.Logger.Printf("<-(ui) %T:%T\n", msg, resp) + worker.Logger.Printf("<-(ui) %T(%d):%T(%d)\n", + msg, msg.getId(), resp, resp.getId()) } else { - worker.Logger.Printf("<-(ui) %T\n", msg) + worker.Logger.Printf("<-(ui) %T(%d)\n", msg, msg.getId()) } if inResponseTo := msg.InResponseTo(); inResponseTo != nil { if f, ok := worker.messageCallbacks[inResponseTo.getId()]; ok { f(msg) + if _, ok := msg.(*Done); ok { + delete(worker.messageCallbacks, inResponseTo.getId()) + } } } return msg |