gtask

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TaskRes

type TaskRes struct {
	Err      error
	Result   chan interface{}
	CostTime float64
}

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

func DoTaskWithContext(ctx context.Context, fn func() interface{}, timeout time.Duration) *TaskRes

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

func DoTaskWithTimeout(fn func() interface{}, timeout time.Duration) *TaskRes

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超时调用

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL