mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-16 21:33:41 +00:00
fix(extension): bound event execution and cancel pending engine calls
This commit is contained in:
1 parent
ed125c2f19
commit
1bc31774cb
7 files changed
+123
-17
No files matched your search
@@ -59,6 +59,21 @@ func (s *engineSession) Release() {
|
||||
}
|
||||
}
|
||||
|
||||
// Close releases retained resources when the owning event is cancelled.
|
||||
func (s *engineSession) Close() {
|
||||
s.mu.Lock()
|
||||
if s.closed {
|
||||
s.mu.Unlock()
|
||||
return
|
||||
}
|
||||
s.closed = true
|
||||
s.mu.Unlock()
|
||||
s.runClosers()
|
||||
if s.engine != nil {
|
||||
s.engine.Close()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *engineSession) CloseIfIdle() {
|
||||
s.mu.Lock()
|
||||
shouldClose := s.refs == 0 && !s.closed
|
||||
|
||||
Reference in new issue
Block a user