Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var FIFOCompare = func(a, b *TaskBlock) bool {
return a.created.Before(b.created)
}
FIFOCompare is a basic task comparator that returns tasks in the order created.
var PriorityCompare = func(a, b *TaskBlock) bool { if a.Target == b.Target { return a.Priority > b.Priority } return FIFOCompare(a, b) }
PriorityCompare respects the target peer's task priority. For tasks involving different peers, the oldest task is prioritized.
Functions ¶
Types ¶
type Identifier ¶
type Identifier interface{}
Identifier is a unique identifier for a task. It's used by the client library to act on a task once it exits the queue.
type Task ¶
type Task struct { Identifier Identifier Priority int }
Task is a single task to be executed as part of a task block.
type TaskBlock ¶
type TaskBlock struct { Tasks []Task Priority int Target peer.ID // A callback to signal that this task block has been completed Done func([]Task) // contains filtered or unexported fields }
TaskBlock is a block of tasks to execute on a single peer.
func NewTaskBlock ¶
NewTaskBlock creates a new task block with the given tasks, priority, target peer, and task completion function.
func (*TaskBlock) MarkPrunable ¶
func (pt *TaskBlock) MarkPrunable(identifier Identifier)
MarkPrunable marks any tasks with the given identifier as prunable at the time the task block is pulled of the queue to execute (because they've already been removed).
func (*TaskBlock) PruneTasks ¶
func (pt *TaskBlock) PruneTasks()
PruneTasks removes all tasks previously marked as prunable from the lists of tasks in the block