Documentation
¶
Index ¶
- Constants
- Variables
- func GetUUID() string
- type AsyncTaskCallBack
- type AsyncTaskHandle
- type AsyncTaskInterface
- type AsyncTaskManagerInterface
- type DefaultAsyncTask
- func (t *DefaultAsyncTask) GetEndUnix() int64
- func (t *DefaultAsyncTask) GetError() error
- func (t *DefaultAsyncTask) GetStartUnix() int64
- func (t *DefaultAsyncTask) GetStatus() uint8
- func (t *DefaultAsyncTask) GetTag() *TaskTag
- func (t *DefaultAsyncTask) SetEndUnix(end int64)
- func (t *DefaultAsyncTask) SetError(e error)
- func (t *DefaultAsyncTask) SetStartUnix(start int64)
- func (t *DefaultAsyncTask) SetStatus(s uint8)
- type DefaultAsyncTaskManager
- func (m *DefaultAsyncTaskManager) AddAsyncTask(t AsyncTaskInterface, h AsyncTaskHandle, cbs ...AsyncTaskCallBack) error
- func (m *DefaultAsyncTaskManager) CheckTaskInWork(workTag string) (bool, error)
- func (m *DefaultAsyncTaskManager) GetManagerStatus() uint8
- func (m *DefaultAsyncTaskManager) GetWaitLength() int
- func (m *DefaultAsyncTaskManager) GetWorkerLength() int
- func (m *DefaultAsyncTaskManager) SetFinishCallBack(f func(*TaskManagerResult))
- func (m *DefaultAsyncTaskManager) SetProgressCallBack(p int, cb ProgressCallBack)
- func (m *DefaultAsyncTaskManager) SetTaskMaxLength(s int)
- func (m *DefaultAsyncTaskManager) SetWaitListMaxLength(l int)
- func (m *DefaultAsyncTaskManager) SetWorkPoolSize(s int)
- func (m *DefaultAsyncTaskManager) Start()
- func (m *DefaultAsyncTaskManager) Stop()
- func (m *DefaultAsyncTaskManager) TaskResultCallBack(res AsyncTaskInterface)
- type ProgressCallBack
- type TaskManagerResult
- type TaskProgress
- type TaskTag
Constants ¶
View Source
const ( ManagerInit uint8 = 0 ManagerStart uint8 = 1 ManagerStop uint8 = 2 ManagerFinish uint8 = 3 ManagerError uint8 = 4 )
View Source
const ( TaskONInit uint8 = 0 TaskONStart uint8 = 1 TaskONStop uint8 = 2 TaskONFinish uint8 = 3 TaskONError uint8 = 4 )
View Source
const ( DefaultWaitLength int = 1000 DefaultWorkLength int = 100 )
View Source
const TaskSep = "##ASYNCTASK%%"
Variables ¶
View Source
var UserStopError error
Functions ¶
Types ¶
type AsyncTaskHandle ¶
type AsyncTaskHandle interface { Start(AsyncTaskInterface) // 开始执行任务 Stop() // 结束任务,然后拉起回调,返回enmu.UserStopError SetHandleCallBack(f AsyncTaskCallBack) // 配置执行的回调 }
type AsyncTaskInterface ¶
type AsyncTaskManagerInterface ¶
type AsyncTaskManagerInterface interface { Start() // 开始 Stop() // 停止 SetWaitListMaxLength(l int) // 设置等待队列的最大长度,默认:1000 SetWorkPoolSize(s int) // 设置并行的数量,默认:100 AddAsyncTask(t AsyncTaskInterface, h AsyncTaskHandle, cb ...AsyncTaskCallBack) error // 增加一个异步任务 SetFinishCallBack(f func(*TaskManagerResult)) // 设置任务完成的回调 CheckTaskInWork(tag string) (bool, error) // 查验任务是否在执行 GetWaitLength() int // 获取当前等待队列长度 GetWorkerLength() int // 获取当前工作队列长度 GetManagerStatus() uint8 // 获取管理器状态 SetTaskMaxLength(s int) // 设置最大任务数 SetProgressCallBack(p int, cb ProgressCallBack) // 设置进度回调 }
AsyncTaskManagerInterface 异步任务管理器通用接口
type DefaultAsyncTask ¶
func (*DefaultAsyncTask) GetEndUnix ¶
func (t *DefaultAsyncTask) GetEndUnix() int64
func (*DefaultAsyncTask) GetError ¶
func (t *DefaultAsyncTask) GetError() error
func (*DefaultAsyncTask) GetStartUnix ¶
func (t *DefaultAsyncTask) GetStartUnix() int64
func (*DefaultAsyncTask) GetStatus ¶
func (t *DefaultAsyncTask) GetStatus() uint8
func (*DefaultAsyncTask) GetTag ¶
func (t *DefaultAsyncTask) GetTag() *TaskTag
func (*DefaultAsyncTask) SetEndUnix ¶
func (t *DefaultAsyncTask) SetEndUnix(end int64)
func (*DefaultAsyncTask) SetError ¶
func (t *DefaultAsyncTask) SetError(e error)
func (*DefaultAsyncTask) SetStartUnix ¶
func (t *DefaultAsyncTask) SetStartUnix(start int64)
func (*DefaultAsyncTask) SetStatus ¶
func (t *DefaultAsyncTask) SetStatus(s uint8)
type DefaultAsyncTaskManager ¶
type DefaultAsyncTaskManager struct {
// contains filtered or unexported fields
}
func NewDefaultAsyncTaskManager ¶
func NewDefaultAsyncTaskManager() *DefaultAsyncTaskManager
func (*DefaultAsyncTaskManager) AddAsyncTask ¶
func (m *DefaultAsyncTaskManager) AddAsyncTask(t AsyncTaskInterface, h AsyncTaskHandle, cbs ...AsyncTaskCallBack) error
func (*DefaultAsyncTaskManager) CheckTaskInWork ¶
func (m *DefaultAsyncTaskManager) CheckTaskInWork(workTag string) (bool, error)
func (*DefaultAsyncTaskManager) GetManagerStatus ¶
func (m *DefaultAsyncTaskManager) GetManagerStatus() uint8
func (*DefaultAsyncTaskManager) GetWaitLength ¶
func (m *DefaultAsyncTaskManager) GetWaitLength() int
func (*DefaultAsyncTaskManager) GetWorkerLength ¶
func (m *DefaultAsyncTaskManager) GetWorkerLength() int
func (*DefaultAsyncTaskManager) SetFinishCallBack ¶
func (m *DefaultAsyncTaskManager) SetFinishCallBack(f func(*TaskManagerResult))
func (*DefaultAsyncTaskManager) SetProgressCallBack ¶
func (m *DefaultAsyncTaskManager) SetProgressCallBack(p int, cb ProgressCallBack)
func (*DefaultAsyncTaskManager) SetTaskMaxLength ¶
func (m *DefaultAsyncTaskManager) SetTaskMaxLength(s int)
func (*DefaultAsyncTaskManager) SetWaitListMaxLength ¶
func (m *DefaultAsyncTaskManager) SetWaitListMaxLength(l int)
func (*DefaultAsyncTaskManager) SetWorkPoolSize ¶
func (m *DefaultAsyncTaskManager) SetWorkPoolSize(s int)
func (*DefaultAsyncTaskManager) Start ¶
func (m *DefaultAsyncTaskManager) Start()
func (*DefaultAsyncTaskManager) Stop ¶
func (m *DefaultAsyncTaskManager) Stop()
func (*DefaultAsyncTaskManager) TaskResultCallBack ¶
func (m *DefaultAsyncTaskManager) TaskResultCallBack(res AsyncTaskInterface)
type ProgressCallBack ¶
type ProgressCallBack func(*TaskProgress)
type TaskManagerResult ¶
type TaskManagerResult struct { StartTime int64 EndTime int64 Length uint64 TagsMap map[string]AsyncTaskInterface Status uint8 }
TaskManagerResult 任务管理器执行结果
type TaskProgress ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.