MCPcopy Create free account
hub / github.com/dc0d/workerpool / Queue

Method Queue

workerpool.go:60–76  ·  view source on GitHub ↗

Queue queues a job to be run by a worker.

(job func(), timeout time.Duration)

Source from the content-addressed store, hash-verified

58
59// Queue queues a job to be run by a worker.
60func (pool *WorkerPool) Queue(job func(), timeout time.Duration) bool {
61 if pool.stopped() {
62 return false
63 }
64 var t <-chan time.Time
65 if timeout > 0 {
66 t = time.After(timeout)
67 }
68 select {
69 case pool.jobs <- job:
70 case <-t:
71 return false
72 case <-pool.quit:
73 return false
74 }
75 return true
76}
77
78// Stop stops the pool and waits for all workers to return.
79func (pool *WorkerPool) Stop() {

Callers 5

TestNegWorkersFunction · 0.80
TestZeroWorkersFunction · 0.80
ExampleWorkerPoolFunction · 0.80
ExampleWorkerPool_ExpandFunction · 0.80

Calls 1

stoppedMethod · 0.95

Tested by 5

TestNegWorkersFunction · 0.64
TestZeroWorkersFunction · 0.64
ExampleWorkerPoolFunction · 0.64
ExampleWorkerPool_ExpandFunction · 0.64