mirror of
https://github.com/langhuihui/monibuca.git
synced 2025-10-25 11:20:21 +08:00
refactor: task system
This commit is contained in:
@@ -12,7 +12,8 @@ import (
|
||||
|
||||
func createMarcoTask() *MarcoTask {
|
||||
var mt MarcoTask
|
||||
mt.initTask(context.Background(), &mt)
|
||||
mt.Context, mt.CancelCauseFunc = context.WithCancelCause(context.Background())
|
||||
mt.handler = &mt
|
||||
mt.Logger = slog.New(slog.NewTextHandler(os.Stdout, nil))
|
||||
return &mt
|
||||
}
|
||||
@@ -67,7 +68,7 @@ func Test_StopByContext(t *testing.T) {
|
||||
mt := createMarcoTask()
|
||||
var task Task
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
mt.AddTaskWithContext(ctx, &task)
|
||||
mt.AddTask(&task, ctx)
|
||||
time.AfterFunc(time.Millisecond*100, cancel)
|
||||
mt.WaitStopped()
|
||||
if !task.StopReasonIs(context.Canceled) {
|
||||
|
||||
Reference in New Issue
Block a user