mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-06-28 02:31:34 +08:00
feat: refactor queue to remove unused methods and add comments
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user