feat: refactor queue to remove unused methods and add comments

This commit is contained in:
krau
2025-12-15 10:49:40 +08:00
parent 45c978980c
commit 651835c467
3 changed files with 60 additions and 177 deletions

View File

@@ -15,6 +15,13 @@ type Task[T any] struct {
element *list.Element
}
// Read-only info about a task
type TaskInfo struct {
ID string
Created time.Time
Cancelled bool
}
func NewTask[T any](ctx context.Context, id string, data T) *Task[T] {
cancelCtx, cancel := context.WithCancel(ctx)
return &Task[T]{
@@ -26,7 +33,7 @@ func NewTask[T any](ctx context.Context, id string, data T) *Task[T] {
}
}
func (t *Task[T]) IsCancelled() bool {
func (t *Task[T]) Cancelled() bool {
select {
case <-t.ctx.Done():
return true