summaryrefslogtreecommitdiff
path: root/static_pool.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-03-31 18:06:31 +0300
committerWolfy-J <[email protected]>2018-03-31 18:06:31 +0300
commitd5fba67987cd6589ceb7a882a027be7612370688 (patch)
tree7d3297817063de3f6b53b24e13a4a5dab9e1da44 /static_pool.go
parent93680a356e2fd30f2502d150b4ef0ad61fcc8a74 (diff)
worker destruction made public
Diffstat (limited to 'static_pool.go')
-rw-r--r--static_pool.go34
1 files changed, 17 insertions, 17 deletions
diff --git a/static_pool.go b/static_pool.go
index 3d036946..2ac6a593 100644
--- a/static_pool.go
+++ b/static_pool.go
@@ -130,23 +130,6 @@ func (p *StaticPool) Exec(rqs *Payload) (rsp *Payload, err error) {
return rsp, nil
}
-// Destroy all underlying workers (but let them to complete the task).
-func (p *StaticPool) Destroy() {
- p.tasks.Wait()
-
- var wg sync.WaitGroup
- for _, w := range p.Workers() {
- wg.Add(1)
- go func(w *Worker) {
- defer wg.Done()
-
- p.DestroyWorker(w)
- }(w)
- }
-
- wg.Wait()
-}
-
// DestroyWorker destroys workers and removes it from the pool.
func (p *StaticPool) DestroyWorker(w *Worker) {
p.throw(EventDestruct, w, nil)
@@ -174,6 +157,23 @@ func (p *StaticPool) DestroyWorker(w *Worker) {
}
}
+// Destroy all underlying workers (but let them to complete the task).
+func (p *StaticPool) Destroy() {
+ p.tasks.Wait()
+
+ var wg sync.WaitGroup
+ for _, w := range p.Workers() {
+ wg.Add(1)
+ go func(w *Worker) {
+ defer wg.Done()
+
+ p.DestroyWorker(w)
+ }(w)
+ }
+
+ wg.Wait()
+}
+
// finds free worker in a given time interval or creates new if allowed.
func (p *StaticPool) allocateWorker() (w *Worker, err error) {
select {