From dc50cc446ef3e9f60c8a5dd705f03a91afc149e1 Mon Sep 17 00:00:00 2001 From: shiroyk Date: Tue, 25 Jun 2024 11:35:29 +0800 Subject: [PATCH] fix: eventloop run done job when stop --- js/eventloop.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/eventloop.go b/js/eventloop.go index bb3da6f..a9b69e5 100644 --- a/js/eventloop.go +++ b/js/eventloop.go @@ -148,7 +148,12 @@ func (e *EventLoop) Stop() { // clean the queue e.queue = e.queue[:0] e.enqueue = 0 - e.doneJobs = e.doneJobs[:0] + if len(e.doneJobs) > 0 { + for _, job := range e.doneJobs { + job() + } + e.doneJobs = e.doneJobs[:0] + } e.cond.Signal() }