Skip to content

Commit

Permalink
Remove unnecessary context wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Dec 16, 2023
1 parent eff46fd commit ce83bad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
22 changes: 0 additions & 22 deletions service/pause/context.go

This file was deleted.

9 changes: 7 additions & 2 deletions service/pause/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/sagernet/sing/common/atomic"
"github.com/sagernet/sing/common/x/list"
"github.com/sagernet/sing/service"
)

type defaultManager struct {
Expand All @@ -18,16 +19,20 @@ type defaultManager struct {
callbacks list.List[Callback]
}

func NewDefaultManager(ctx context.Context) Manager {
func WithDefaultManager(ctx context.Context) context.Context {
if service.FromContext[Manager](ctx) != nil {
return ctx
}
devicePauseChan := make(chan struct{})
networkPauseChan := make(chan struct{})
close(devicePauseChan)
close(networkPauseChan)
return &defaultManager{
manager := &defaultManager{
ctx: ctx,
devicePause: devicePauseChan,
networkPause: networkPauseChan,
}
return service.ContextWith[Manager](ctx, manager)
}

func (d *defaultManager) DevicePause() {
Expand Down

0 comments on commit ce83bad

Please sign in to comment.