Documentation ¶
Index ¶
- Constants
- Variables
- func CheckPoint(ctx context.Context)
- func Disable()
- func Enable()
- func Scheduler(opts ...Option)
- func WithSchedInfo(ctx context.Context) context.Context
- type Option
- type PriorityQueue
- func (pq *PriorityQueue) Dequeue() *TaskGroup
- func (pq *PriorityQueue) Empty() bool
- func (pq *PriorityQueue) Enqueue(x *TaskGroup)
- func (pq *PriorityQueue) Full() bool
- func (pq *PriorityQueue) Len() int
- func (pq *PriorityQueue) Less(i, j int) bool
- func (pq *PriorityQueue) Pop() interface{}
- func (pq *PriorityQueue) Push(x interface{})
- func (pq *PriorityQueue) Swap(i, j int)
- type TaskContext
- type TaskGroup
Constants ¶
const ( Stable feedbackPhase = iota Idle Busy GC )
Variables ¶
var Debug = "schedTest"
Functions ¶
func CheckPoint ¶
CheckPoint should be called manually to check whether the goroutine (task group) run out of its time slice. If so, the goroutine is yielded for scheduling. The scheduler will wake up it according to the scheduling algorithm.
Types ¶
type Option ¶
type Option func(*config)
Option overrides the default scheduling parameters.
func CapacityOption ¶
CapacityOption controls the token bucket capacity, which controls the burst behaviour. Default value is GOMAXPROCS * time slice, DONOT SET IT TO 0
func LoadOption ¶
LoadOption controls the `load` of the CPU usage, default to 1
func TimeSliceOption ¶
TimeSliceOption controls the time-slice of a task group. It's default to 20ms
func WeightedOption ¶
WeightedOption make the scheduling support weighted task group, rather than regarding as all equal.
type PriorityQueue ¶
type PriorityQueue struct {
// contains filtered or unexported fields
}
func (*PriorityQueue) Dequeue ¶
func (pq *PriorityQueue) Dequeue() *TaskGroup
func (*PriorityQueue) Empty ¶
func (pq *PriorityQueue) Empty() bool
func (*PriorityQueue) Enqueue ¶
func (pq *PriorityQueue) Enqueue(x *TaskGroup)
func (*PriorityQueue) Full ¶
func (pq *PriorityQueue) Full() bool
func (*PriorityQueue) Len ¶
func (pq *PriorityQueue) Len() int
func (*PriorityQueue) Less ¶
func (pq *PriorityQueue) Less(i, j int) bool
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() interface{}
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(x interface{})
func (*PriorityQueue) Swap ¶
func (pq *PriorityQueue) Swap(i, j int)
type TaskContext ¶
type TaskContext struct {
// contains filtered or unexported fields
}
type TaskGroup ¶
type TaskGroup struct {
// contains filtered or unexported fields
}
func NewTaskGroup ¶
NewTaskGroup returns a new context with TaskGroup attached using context.WithValue. A task group is a scheduling unit consist of a group of goroutines. The necessary information for scheduling is embeded in the context.Context.