-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPool_test.go
More file actions
33 lines (31 loc) · 1.05 KB
/
Copy pathPool_test.go
File metadata and controls
33 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package gopool
import (
"fmt"
"testing"
"time"
)
func TestPool(t *testing.T) {
pool, _ := NewPool("test", 10, 1, 1, 1, 5*time.Second)
_ = pool.Enqueue(NewMission("1", 1, time.Now().Add(1*time.Second), true, func() {
fmt.Println("hello world 1")
time.Sleep(1 * time.Second)
}))
_ = pool.Enqueue(NewMission("2", 1, time.Now().Add(5*time.Second), true, func() {
fmt.Println("hello world 2")
time.Sleep(1 * time.Second)
}))
_ = pool.Enqueue(NewMission("3", 1, time.Now().Add(5*time.Second), true, func() {
fmt.Println("hello world 3")
time.Sleep(1 * time.Second)
}))
_ = pool.Enqueue(NewMission("4", 2, time.Now().Add(5*time.Second), true, func() {
fmt.Println("hello world 4")
}))
_ = pool.Enqueue(NewMission("5", 2, time.Now().Add(5*time.Second), true, func() {
fmt.Println("hello world 5")
}))
_ = pool.Enqueue(NewMission("9", 9, time.Now().Add(5*time.Second), true, func() {
fmt.Println("hello world 9")
}))
time.Sleep(5 * time.Second)
}