github.com/ilhicas/nomad@v0.11.8/drivers/docker/state.go (about)

     1  package docker
     2  
     3  import (
     4  	"sync"
     5  )
     6  
     7  type taskStore struct {
     8  	store map[string]*taskHandle
     9  	lock  sync.RWMutex
    10  }
    11  
    12  func newTaskStore() *taskStore {
    13  	return &taskStore{store: map[string]*taskHandle{}}
    14  }
    15  
    16  func (ts *taskStore) Set(id string, handle *taskHandle) {
    17  	ts.lock.Lock()
    18  	defer ts.lock.Unlock()
    19  	ts.store[id] = handle
    20  }
    21  
    22  func (ts *taskStore) Get(id string) (*taskHandle, bool) {
    23  	ts.lock.RLock()
    24  	defer ts.lock.RUnlock()
    25  	t, ok := ts.store[id]
    26  	return t, ok
    27  }
    28  
    29  func (ts *taskStore) Delete(id string) {
    30  	ts.lock.Lock()
    31  	defer ts.lock.Unlock()
    32  	delete(ts.store, id)
    33  }