forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove unnecessary
PriorityMutex
implementation (argoproj…
…#13337) Signed-off-by: Alan Clucas <[email protected]>
- Loading branch information
Showing
2 changed files
with
13 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,6 @@ | ||
package sync | ||
|
||
import ( | ||
"sync" | ||
"time" | ||
) | ||
|
||
type PriorityMutex struct { | ||
name string | ||
mutex *PrioritySemaphore | ||
lock *sync.Mutex | ||
} | ||
|
||
func (m *PriorityMutex) getCurrentPending() []string { | ||
return m.mutex.getCurrentPending() | ||
} | ||
|
||
var _ Semaphore = &PriorityMutex{} | ||
|
||
// NewMutex creates new mutex lock object | ||
// name of the mutex | ||
// callbackFunc is a release notification function. | ||
func NewMutex(name string, nextWorkflow NextWorkflow) *PriorityMutex { | ||
return &PriorityMutex{ | ||
name: name, | ||
lock: &sync.Mutex{}, | ||
mutex: NewSemaphore(name, 1, nextWorkflow, "mutex"), | ||
} | ||
} | ||
|
||
func (m *PriorityMutex) getName() string { | ||
return m.name | ||
} | ||
|
||
func (m *PriorityMutex) getLimit() int { | ||
return m.mutex.limit | ||
} | ||
|
||
func (m *PriorityMutex) getCurrentHolders() []string { | ||
return m.mutex.getCurrentHolders() | ||
} | ||
|
||
func (m *PriorityMutex) resize(n int) bool { | ||
return false | ||
} | ||
|
||
func (m *PriorityMutex) release(key string) bool { | ||
m.lock.Lock() | ||
defer m.lock.Unlock() | ||
return m.mutex.release(key) | ||
} | ||
|
||
func (m *PriorityMutex) acquire(holderKey string) bool { | ||
m.lock.Lock() | ||
defer m.lock.Unlock() | ||
return m.mutex.acquire(holderKey) | ||
} | ||
|
||
func (m *PriorityMutex) addToQueue(holderKey string, priority int32, creationTime time.Time) { | ||
m.lock.Lock() | ||
defer m.lock.Unlock() | ||
m.mutex.addToQueue(holderKey, priority, creationTime) | ||
} | ||
|
||
func (m *PriorityMutex) removeFromQueue(holderKey string) { | ||
m.lock.Lock() | ||
defer m.lock.Unlock() | ||
m.mutex.removeFromQueue(holderKey) | ||
} | ||
|
||
func (m *PriorityMutex) tryAcquire(holderKey string) (bool, string) { | ||
m.lock.Lock() | ||
defer m.lock.Unlock() | ||
return m.mutex.tryAcquire(holderKey) | ||
// NewMutex creates a size 1 semaphore | ||
func NewMutex(name string, nextWorkflow NextWorkflow) *PrioritySemaphore { | ||
return NewSemaphore(name, 1, nextWorkflow, "mutex") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters