File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -200,6 +200,11 @@ func (k *ShutdownKeeper) DeadlineContext() context.Context {
200200 return k .deadlineCtx
201201}
202202
203+ // DoOnShutdown is just a shortcut for HoldToken's DoOnShutdown method.
204+ func (k * ShutdownKeeper ) DoOnShutdown (f func (ctx context.Context )) {
205+ k .AllocHoldToken ().DoOnShutdown (f )
206+ }
207+
203208func (k * ShutdownKeeper ) doAllocToken (allocFunc func (releaseCallback func ()) HoldToken ) HoldToken {
204209 atomic .AddInt32 (& k .holdTokenNum , 1 )
205210 return allocFunc (sync .OnceFunc (k .doReleaseToken ))
Original file line number Diff line number Diff line change @@ -65,12 +65,12 @@ func TestShutdownKeeper_HoldTokens(t *testing.T) {
6565
6666 start := time .Now ()
6767 var actual int32
68- keeper .AllocHoldToken (). DoOnShutdown (func (_ context.Context ) {
68+ keeper .DoOnShutdown (func (_ context.Context ) {
6969 time .Sleep (time .Second )
7070 atomic .AddInt32 (& actual , 1 )
7171 })
7272
73- keeper .AllocHoldToken (). DoOnShutdown (func (_ context.Context ) {
73+ keeper .DoOnShutdown (func (_ context.Context ) {
7474 time .Sleep (500 * time .Millisecond )
7575 atomic .AddInt32 (& actual , 1 )
7676 })
You can’t perform that action at this time.
0 commit comments