Documentation
¶
Index ¶
- type PriorityQueue
- type Scheduler
- func (s *Scheduler[P, R]) CancelTaskByID(taskID string) bool
- func (s *Scheduler[P, R]) GetTaskPosition(taskID string) int
- func (s *Scheduler[P, R]) QueueLen() int
- func (s *Scheduler[P, R]) RunningCount() int32
- func (s *Scheduler[P, R]) SubmitTask(ctx context.Context, priority int, param P, ...) *Task[P, R]
- type Task
- type TaskPool
- func (tp *TaskPool[P, R]) AddTask(ctx context.Context, param P, ...) (*Task[P, R], error)
- func (tp *TaskPool[P, R]) CancelTask(task *Task[P, R])
- func (tp *TaskPool[P, R]) QueueLen() int
- func (tp *TaskPool[P, R]) Running() int32
- func (tp *TaskPool[P, R]) Wait()
- func (tp *TaskPool[P, R]) WorkerCount() int
- type TaskPoolOption
- type TaskStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PriorityQueue ¶
type PriorityQueue struct {
// contains filtered or unexported fields
}
func (*PriorityQueue) GetPosition ¶
func (pq *PriorityQueue) GetPosition(taskID string) int
func (*PriorityQueue) Len ¶
func (pq *PriorityQueue) Len() int
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(task any, priority int, taskID string)
Push 存储 taskID + priority + 原始任务
func (*PriorityQueue) Remove ¶
func (pq *PriorityQueue) Remove(taskID string) bool
type Scheduler ¶
type Scheduler[P, R any] struct { // contains filtered or unexported fields }
func NewScheduler ¶
func (*Scheduler[P, R]) CancelTaskByID ¶
func (*Scheduler[P, R]) GetTaskPosition ¶
func (*Scheduler[P, R]) RunningCount ¶
type TaskPool ¶
func NewTaskPool ¶
func NewTaskPool[Param any, Result any](options *TaskPoolOption) *TaskPool[Param, Result]
func (*TaskPool[P, R]) CancelTask ¶
func (*TaskPool[P, R]) WorkerCount ¶
type TaskPoolOption ¶
type TaskStatus ¶
type TaskStatus string
const ( TaskStatusPending TaskStatus = "pending" TaskStatusRunning TaskStatus = "running" TaskStatusSuccess TaskStatus = "success" TaskStatusFailed TaskStatus = "failed" TaskStatusCancel TaskStatus = "canceled" )
func (TaskStatus) ToString ¶
func (ts TaskStatus) ToString() string
Click to show internal directories.
Click to hide internal directories.