You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
naza/pkg/defertaskthread/defertaskthread_test.go

30 lines
650 B
Go

// Copyright 2020, Chef. All rights reserved.
// https://github.com/q191201771/naza
//
// Use of this source code is governed by a MIT-style license
// that can be found in the License file.
//
// Author: Chef (191201771@qq.com)
package defertaskthread_test
import (
"testing"
"time"
"github.com/q191201771/naza/pkg/nazalog"
"github.com/q191201771/naza/pkg/defertaskthread"
)
func TestDeferTaskThread(t *testing.T) {
d := defertaskthread.NewDeferTaskThread()
for i := 0; i < 300; i += 50 {
d.Go(i, func(param ...interface{}) {
ii := param[0].(int)
nazalog.Debugf("running %d", ii)
}, i)
}
time.Sleep(300 * time.Millisecond)
}