summaryrefslogtreecommitdiff
path: root/pkg/worker_watcher/container/vec.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-08-12 15:38:19 +0300
committerGitHub <[email protected]>2021-08-12 15:38:19 +0300
commitdf27287c78d7b17d7c8f0e7fff59fa7cbf2a4f9f (patch)
treedf0749155487eae6bcdbb2456885131a21916f4d /pkg/worker_watcher/container/vec.go
parent67db4b5f7b66e9a32713133baed83c3ab7146bb8 (diff)
parentecbfc5c5265a9895f4e371ce4388f64df8714e63 (diff)
#726: feat(plugin): new `jobs` plugin
#726: feat(plugin): new `jobs` plugin
Diffstat (limited to 'pkg/worker_watcher/container/vec.go')
-rw-r--r--pkg/worker_watcher/container/vec.go51
1 files changed, 0 insertions, 51 deletions
diff --git a/pkg/worker_watcher/container/vec.go b/pkg/worker_watcher/container/vec.go
deleted file mode 100644
index 24b5fa6d..00000000
--- a/pkg/worker_watcher/container/vec.go
+++ /dev/null
@@ -1,51 +0,0 @@
-package container
-
-import (
- "context"
- "sync/atomic"
-
- "github.com/spiral/errors"
- "github.com/spiral/roadrunner/v2/pkg/worker"
-)
-
-type Vec struct {
- destroy uint64
- workers chan worker.BaseProcess
-}
-
-func NewVector(initialNumOfWorkers uint64) *Vec {
- vec := &Vec{
- destroy: 0,
- workers: make(chan worker.BaseProcess, initialNumOfWorkers),
- }
-
- return vec
-}
-
-func (v *Vec) Enqueue(w worker.BaseProcess) {
- v.workers <- w
-}
-
-func (v *Vec) Dequeue(ctx context.Context) (worker.BaseProcess, error) {
- /*
- if *addr == old {
- *addr = new
- return true
- }
- */
-
- if atomic.CompareAndSwapUint64(&v.destroy, 1, 1) {
- return nil, errors.E(errors.WatcherStopped)
- }
-
- select {
- case w := <-v.workers:
- return w, nil
- case <-ctx.Done():
- return nil, errors.E(ctx.Err(), errors.NoFreeWorkers)
- }
-}
-
-func (v *Vec) Destroy() {
- atomic.StoreUint64(&v.destroy, 1)
-}