Documentation ¶
Index ¶
- type TaskRes
- func DoTask(fn func() interface{}) *TaskRes
- func DoTaskWithArgs(fn func(args ...interface{}) interface{}, args ...interface{}) *TaskRes
- func DoTaskWithContext(ctx context.Context, fn func() interface{}, timeout time.Duration) *TaskRes
- func DoTaskWithContextArgs(ctx context.Context, fn func(args ...interface{}) interface{}, ...) *TaskRes
- func DoTaskWithTimeout(fn func() interface{}, timeout time.Duration) *TaskRes
- func DoTaskWithTimeoutArgs(fn func(args ...interface{}) interface{}, timeout time.Duration, ...) *TaskRes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TaskRes ¶
TaskRes task返回的结果
func DoTask ¶
func DoTask(fn func() interface{}) *TaskRes
DoTask 在独立携程中运行fn 这里返回结果设计为interface{},因为有时候返回结果可以是error
func DoTaskWithArgs ¶
func DoTaskWithArgs(fn func(args ...interface{}) interface{}, args ...interface{}) *TaskRes
DoTaskWithArgs 在独立携程中执行有参数的fn
func DoTaskWithContext ¶
DoTaskWithContext 通过上下文context+done+select实现goroutine超时调用
func DoTaskWithContextArgs ¶
func DoTaskWithContextArgs(ctx context.Context, fn func(args ...interface{}) interface{}, timeout time.Duration, args ...interface{}) *TaskRes
DoTaskWithContextArgs 通过上下文context+done+select实现goroutine超时调用
func DoTaskWithTimeout ¶
DoTaskWithTimeout 采用done+select+time.After实现goroutine超时调用
func DoTaskWithTimeoutArgs ¶
func DoTaskWithTimeoutArgs(fn func(args ...interface{}) interface{}, timeout time.Duration, args ...interface{}) *TaskRes
DoTaskWithTimeoutArgs 采用done+select+time.After实现goroutine超时调用
Click to show internal directories.
Click to hide internal directories.