forked from mirror/ants
change some comments
This commit is contained in:
parent
5326374a22
commit
4b806f461b
12
worker.go
12
worker.go
|
@ -26,9 +26,9 @@ import (
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Worker is the actual executor who run the tasks,
|
// Worker is the actual executor who runs the tasks,
|
||||||
// it will start a goroutine that accept tasks and
|
// it starts a goroutine that accepts tasks and
|
||||||
// perform function calls.
|
// performs function calls.
|
||||||
type Worker struct {
|
type Worker struct {
|
||||||
// pool who owns this worker.
|
// pool who owns this worker.
|
||||||
pool *Pool
|
pool *Pool
|
||||||
|
@ -37,8 +37,8 @@ type Worker struct {
|
||||||
task chan f
|
task chan f
|
||||||
}
|
}
|
||||||
|
|
||||||
// run will start a goroutine to repeat the process
|
// run starts a goroutine to repeat the process
|
||||||
// that perform the function calls.
|
// that performs the function calls.
|
||||||
func (w *Worker) run() {
|
func (w *Worker) run() {
|
||||||
//atomic.AddInt32(&w.pool.running, 1)
|
//atomic.AddInt32(&w.pool.running, 1)
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -58,7 +58,7 @@ func (w *Worker) stop() {
|
||||||
w.task <- nil
|
w.task <- nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// sendTask send a task to this worker.
|
// sendTask sends a task to this worker.
|
||||||
func (w *Worker) sendTask(task f) {
|
func (w *Worker) sendTask(task f) {
|
||||||
w.task <- task
|
w.task <- task
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,9 @@ import (
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Worker is the actual executor who run the tasks,
|
// WorkerWithFunc is the actual executor who runs the tasks,
|
||||||
// it will start a goroutine that accept tasks and
|
// it starts a goroutine that accepts tasks and
|
||||||
// perform function calls.
|
// performs function calls.
|
||||||
type WorkerWithFunc struct {
|
type WorkerWithFunc struct {
|
||||||
// pool who owns this worker.
|
// pool who owns this worker.
|
||||||
pool *PoolWithFunc
|
pool *PoolWithFunc
|
||||||
|
@ -37,8 +37,8 @@ type WorkerWithFunc struct {
|
||||||
args chan interface{}
|
args chan interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// run will start a goroutine to repeat the process
|
// run starts a goroutine to repeat the process
|
||||||
// that perform the function calls.
|
// that performs the function calls.
|
||||||
func (w *WorkerWithFunc) run() {
|
func (w *WorkerWithFunc) run() {
|
||||||
//atomic.AddInt32(&w.pool.running, 1)
|
//atomic.AddInt32(&w.pool.running, 1)
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -58,7 +58,7 @@ func (w *WorkerWithFunc) stop() {
|
||||||
w.args <- nil
|
w.args <- nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// sendTask send a task to this worker.
|
// sendTask sends a task to this worker.
|
||||||
func (w *WorkerWithFunc) sendTask(args interface{}) {
|
func (w *WorkerWithFunc) sendTask(args interface{}) {
|
||||||
w.args <- args
|
w.args <- args
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue