mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-09 17:44:59 +09:00
cancel context for app.close
This commit is contained in:
parent
c697059179
commit
90a7e2da1f
1 changed files with 5 additions and 0 deletions
|
@ -78,6 +78,7 @@ type entry struct {
|
|||
load chan struct{}
|
||||
loadErr error
|
||||
value Object
|
||||
cancel func()
|
||||
}
|
||||
|
||||
type OCache interface {
|
||||
|
@ -142,6 +143,7 @@ func (c *oCache) Get(ctx context.Context, id string) (value Object, err error) {
|
|||
id: id,
|
||||
load: make(chan struct{}),
|
||||
}
|
||||
ctx, e.cancel = context.WithCancel(ctx)
|
||||
c.data[id] = e
|
||||
}
|
||||
e.lastUsage = c.timeNow()
|
||||
|
@ -358,6 +360,9 @@ func (c *oCache) Close() (err error) {
|
|||
}
|
||||
c.mu.Unlock()
|
||||
for _, e := range toClose {
|
||||
if e.cancel != nil {
|
||||
e.cancel()
|
||||
}
|
||||
<-e.load
|
||||
if e.value != nil {
|
||||
if clErr := e.value.Close(); clErr != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue