Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ type contextTask struct {
task Task
}

// UpdateTask wraps task with ctx so the task can observe cancellation and
// deadlines while it is waiting in or executing from the pool.
func UpdateTask(ctx context.Context, task Task) *contextTask {
return &contextTask{ctx: ctx, task: task}
}

func (t *contextTask) Process() {
if t.ctx.Err() != nil {
return
Expand Down
2 changes: 1 addition & 1 deletion test/count.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"runtime"
"time"

agilepool "github.com/Yiming1997/agilePool"
agilepool "github.com/Yiming1997/agilePool/v2"
"github.com/shirou/gopsutil/v3/cpu"
)

Expand Down
2 changes: 1 addition & 1 deletion test/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"sync/atomic"
"time"

agilepool "github.com/Yiming1997/agilePool"
agilepool "github.com/Yiming1997/agilePool/v2"
)

// TaskType controls how simulated task durations are generated.
Expand Down
4 changes: 2 additions & 2 deletions test/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module agilepool-test
go 1.23.4

require (
github.com/Yiming1997/agilePool v0.0.0
github.com/Yiming1997/agilePool/v2 v2.0.0
github.com/shirou/gopsutil/v3 v3.24.5
)

Expand All @@ -18,4 +18,4 @@ require (
golang.org/x/sys v0.20.0 // indirect
)

replace github.com/Yiming1997/agilePool => ../
replace github.com/Yiming1997/agilePool/v2 => ../
2 changes: 1 addition & 1 deletion test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"runtime/pprof"
"time"

agilepool "github.com/Yiming1997/agilePool"
agilepool "github.com/Yiming1997/agilePool/v2"
)

func main() {
Expand Down
Loading