mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
21 lines
331 B
Go
21 lines
331 B
Go
|
package bbgo
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"sync"
|
||
|
)
|
||
|
|
||
|
//go:generate callbackgen -type Graceful
|
||
|
type Graceful struct {
|
||
|
shutdownCallbacks []func(ctx context.Context, wg *sync.WaitGroup)
|
||
|
}
|
||
|
|
||
|
func (g *Graceful) Shutdown(ctx context.Context) {
|
||
|
var wg sync.WaitGroup
|
||
|
wg.Add(len(g.shutdownCallbacks))
|
||
|
|
||
|
go g.EmitShutdown(ctx, &wg)
|
||
|
|
||
|
wg.Wait()
|
||
|
}
|