MCPcopy Create free account
hub / github.com/LyricTian/queue / ExampleQueue

Function ExampleQueue

chan_queue_test.go:50–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

48}
49
50func ExampleQueue() {
51 q := NewQueue(1, 10)
52 q.Run()
53
54 var count int64
55
56 for i := 0; i < 10; i++ {
57 job := NewJob("foo", func(v interface{}) {
58 atomic.AddInt64(&count, 1)
59 })
60 q.Push(job)
61 }
62
63 q.Terminate()
64 fmt.Println(count)
65 // output: 10
66}
67
68func BenchmarkQueue(b *testing.B) {
69 q := NewQueue(10, 100)

Callers

nothing calls this directly

Calls 5

RunMethod · 0.95
PushMethod · 0.95
TerminateMethod · 0.95
NewQueueFunction · 0.85
NewJobFunction · 0.85

Tested by

no test coverage detected