summaryrefslogtreecommitdiff
path: root/oci/memory_store.go
diff options
context:
space:
mode:
authorumohnani8 <umohnani@redhat.com>2017-12-11 10:20:22 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2017-12-14 13:56:20 +0000
commit05f4dd9f41707959ce801f9851c79232a1b79dca (patch)
treeed4cfc80c90204f6166379f4f2c368ac57d480f1 /oci/memory_store.go
parent900afc929f01ef2a38b69263e35c964284f1f9f4 (diff)
downloadpodman-05f4dd9f41707959ce801f9851c79232a1b79dca.tar.gz
podman-05f4dd9f41707959ce801f9851c79232a1b79dca.tar.bz2
podman-05f4dd9f41707959ce801f9851c79232a1b79dca.zip
Clear up fragments of the old api
As everything is being moved over to the new container api removing files that depended on the old api Signed-off-by: umohnani8 <umohnani@redhat.com> Closes: #116 Approved by: rhatdan
Diffstat (limited to 'oci/memory_store.go')
-rw-r--r--oci/memory_store.go92
1 files changed, 0 insertions, 92 deletions
diff --git a/oci/memory_store.go b/oci/memory_store.go
deleted file mode 100644
index 6223ce7f0..000000000
--- a/oci/memory_store.go
+++ /dev/null
@@ -1,92 +0,0 @@
-package oci
-
-import "sync"
-
-// memoryStore implements a Store in memory.
-type memoryStore struct {
- s map[string]*Container
- sync.RWMutex
-}
-
-// NewMemoryStore initializes a new memory store.
-func NewMemoryStore() ContainerStorer {
- return &memoryStore{
- s: make(map[string]*Container),
- }
-}
-
-// Add appends a new container to the memory store.
-// It overrides the id if it existed before.
-func (c *memoryStore) Add(id string, cont *Container) {
- c.Lock()
- c.s[id] = cont
- c.Unlock()
-}
-
-// Get returns a container from the store by id.
-func (c *memoryStore) Get(id string) *Container {
- c.RLock()
- res := c.s[id]
- c.RUnlock()
- return res
-}
-
-// Delete removes a container from the store by id.
-func (c *memoryStore) Delete(id string) {
- c.Lock()
- delete(c.s, id)
- c.Unlock()
-}
-
-// List returns a sorted list of containers from the store.
-// The containers are ordered by creation date.
-func (c *memoryStore) List() []*Container {
- containers := History(c.all())
- containers.sort()
- return containers
-}
-
-// Size returns the number of containers in the store.
-func (c *memoryStore) Size() int {
- c.RLock()
- defer c.RUnlock()
- return len(c.s)
-}
-
-// First returns the first container found in the store by a given filter.
-func (c *memoryStore) First(filter StoreFilter) *Container {
- for _, cont := range c.all() {
- if filter(cont) {
- return cont
- }
- }
- return nil
-}
-
-// ApplyAll calls the reducer function with every container in the store.
-// This operation is asynchronous in the memory store.
-// NOTE: Modifications to the store MUST NOT be done by the StoreReducer.
-func (c *memoryStore) ApplyAll(apply StoreReducer) {
- wg := new(sync.WaitGroup)
- for _, cont := range c.all() {
- wg.Add(1)
- go func(container *Container) {
- apply(container)
- wg.Done()
- }(cont)
- }
-
- wg.Wait()
-}
-
-func (c *memoryStore) all() []*Container {
- c.RLock()
- containers := make([]*Container, 0, len(c.s))
- for _, cont := range c.s {
- containers = append(containers, cont)
- }
- c.RUnlock()
- return containers
-}
-
-var _ ContainerStorer = &memoryStore{}