-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdoc.go
45 lines (33 loc) · 1.11 KB
/
doc.go
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
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2016 Duzy Chan <[email protected]>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/*
Package worker implements an easy to use concurrency framework for
multiple-job Go program.
Here is a quick example demonstrating the usage.
package example
import "github.com/duzy/worker"
type SomeJob struct {
Param string
}
func (job *SomeJob) Action() worker.Result {
// ...
return &SomeJobResponder{}
}
type SomeJobResponder struct {
}
func (res *SomeJobResponder) Action() {
// ...
}
const NumberOfConcurrency = 10
func main() {
w := worker.New()
w.StartN(NumberOfConcurrency)
w.Do(&SomeJob{ "anything goes" })
w.Do(&SomeJob{ "anything goes" })
w.Do(&SomeJob{ "anything goes" })
w.Do(&SomeJob{ "anything goes" })
w.StopN(NumberOfConcurrency)
}
*/
package worker