summaryrefslogtreecommitdiff
path: root/libvirt/pool_sync.go
diff options
context:
space:
mode:
Diffstat (limited to 'libvirt/pool_sync.go')
-rw-r--r--libvirt/pool_sync.go49
1 files changed, 0 insertions, 49 deletions
diff --git a/libvirt/pool_sync.go b/libvirt/pool_sync.go
deleted file mode 100644
index a50528bc..00000000
--- a/libvirt/pool_sync.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package libvirt
-
-import (
- "sync"
-)
-
-// LVirtPoolSync makes possible to synchronize operations
-// against libvirt pools.
-// Doing pool.Refresh() operations while uploading or removing
-// a volume into the pool causes errors inside of libvirtd
-type LVirtPoolSync struct {
- PoolLocks map[string]*sync.Mutex
- internalMutex sync.Mutex
-}
-
-// NewLVirtPoolSync allocates a new instance of LVirtPoolSync
-func NewLVirtPoolSync() LVirtPoolSync {
- pool := LVirtPoolSync{}
- pool.PoolLocks = make(map[string]*sync.Mutex)
-
- return pool
-}
-
-// AcquireLock acquires a lock for the specified pool
-func (ps LVirtPoolSync) AcquireLock(pool string) {
- ps.internalMutex.Lock()
- defer ps.internalMutex.Unlock()
-
- lock, exists := ps.PoolLocks[pool]
- if !exists {
- lock = new(sync.Mutex)
- ps.PoolLocks[pool] = lock
- }
-
- lock.Lock()
-}
-
-// ReleaseLock releases the look for the specified pool
-func (ps LVirtPoolSync) ReleaseLock(pool string) {
- ps.internalMutex.Lock()
- defer ps.internalMutex.Unlock()
-
- lock, exists := ps.PoolLocks[pool]
- if !exists {
- return
- }
-
- lock.Unlock()
-}