summaryrefslogtreecommitdiff
path: root/static_pool.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2019-05-03 15:44:51 +0300
committerWolfy-J <[email protected]>2019-05-03 15:44:51 +0300
commit28c787d66c2b74dd2300c792abd1e4f987c3d6c9 (patch)
treeb9c5ef036eda3ffa16b5e87a06ce99fcd8a4d7b4 /static_pool.go
parente9d42947a6922ce2f0aa9f9bcab4ead167735bc9 (diff)
new watchers functionality
Diffstat (limited to 'static_pool.go')
-rw-r--r--static_pool.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/static_pool.go b/static_pool.go
index 5f60099a..02960825 100644
--- a/static_pool.go
+++ b/static_pool.go
@@ -116,13 +116,18 @@ func (p *StaticPool) Workers() (workers []*Worker) {
}
// Remove forces pool to remove specific worker.
-func (p *StaticPool) Remove(w *Worker, err error) {
+func (p *StaticPool) Remove(w *Worker, err error) bool {
if w.State().Value() != StateReady && w.State().Value() != StateWorking {
// unable to remove inactive worker
- return
+ return false
+ }
+
+ if _, ok := p.remove.Load(w); ok {
+ return false
}
p.remove.Store(w, err)
+ return true
}
// Exec one task with given payload and context, returns result or error.