-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexport.go
72 lines (55 loc) · 1.62 KB
/
export.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package workpool
import (
"time"
"github.com/nextzhou/workpool/wpcore"
)
// nolint: gochecknoglobals,nolintlint
var (
New = wpcore.New
Options options
Wraps wraps
)
type (
Task = wpcore.Task
)
// wraps exports task wraps from wpcore.
type wraps struct{}
func (wraps) PanicAsError(task Task) Task {
return wpcore.PanicAsError(task)
}
func (wraps) Phased(task wpcore.PhasedTask) (Task, wpcore.PhasedTaskSupervisor) {
return wpcore.Phased(task)
}
func (wraps) RunStopTask(run, stop func() error) Task {
return wpcore.RunStopTask(run, stop)
}
// options exports options from wpcore.
type options struct{}
func (options) TaskTimeout(timeout time.Duration) wpcore.Option {
return wpcore.WithTaskTimeout(timeout)
}
func (options) Recover(r wpcore.Recover) wpcore.Option {
return wpcore.WithRecover(r)
}
func (options) ExitTogether() wpcore.Option {
return wpcore.WithExitTogether()
}
func (options) WrapsChain(wraps ...wpcore.TaskWrap) wpcore.Option {
return wpcore.WithWrapsChain(wraps...)
}
func (options) SkipPendingTask(asError bool) wpcore.Option {
return wpcore.SkipPendingTask(asError)
}
func (options) ParallelLimit(limit uint) wpcore.Option {
return wpcore.WithParallelLimit(limit)
}
// Deprecated: tasks will not be skipped by default now.
// Use SkipPendingTask(false) instead.
func (options) IgnoreSkippingPendingErr() wpcore.Option {
return wpcore.SkipPendingTask(false)
}
// Deprecated: tasks will not be skipped by default now.
// If you want to skip the pending task when the context canceled, use SkipPendingTask() instead.
func (options) DontSkipTask() wpcore.Option {
return wpcore.WithDontSkipTask()
}