Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7dc2fb0e77 |
@ -21,7 +21,7 @@ type IContext interface {
|
||||
Set(key string, data any)
|
||||
Get(key string) (any, bool)
|
||||
RemoveMetaData(key string)
|
||||
CleanupIn(lifetime time.Duration)
|
||||
CleanupIn(lifetime time.Duration, onCleanup ...func())
|
||||
Dispatch(event IEvent, filter func(c IContext) bool)
|
||||
IsCaller(c IContext) bool
|
||||
}
|
||||
@ -88,7 +88,7 @@ func (context *context) RemoveMetaData(key string) {
|
||||
delete(context.metadata, key)
|
||||
}
|
||||
|
||||
func (context *context) CleanupIn(lifetime time.Duration) {
|
||||
func (context *context) CleanupIn(lifetime time.Duration, onCleanup ...func()) {
|
||||
context.mutex.Lock()
|
||||
defer context.mutex.Unlock()
|
||||
|
||||
@ -104,6 +104,9 @@ func (context *context) CleanupIn(lifetime time.Duration) {
|
||||
|
||||
if context.timer != nil {
|
||||
di.Destroy[IContext](context.id)
|
||||
for _, cleaner := range onCleanup {
|
||||
cleaner()
|
||||
}
|
||||
context.timer = nil
|
||||
}
|
||||
}(context.id)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user