Skip to content

Commit

Permalink
Use RWMutex in framework
Browse files Browse the repository at this point in the history
Signed-off-by: kerthcet <kerthcet@gmail.com>
  • Loading branch information
kerthcet committed Oct 16, 2022
1 parent 6aa1b61 commit bf26553
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/scheduler/framework/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"k8s.io/klog"
)

var pluginMutex sync.Mutex
var pluginMutex sync.RWMutex

// PluginBuilder plugin management
type PluginBuilder = func(Arguments) Plugin
Expand All @@ -52,8 +52,8 @@ func CleanupPluginBuilders() {

// GetPluginBuilder get the pluginbuilder by name
func GetPluginBuilder(name string) (PluginBuilder, bool) {
pluginMutex.Lock()
defer pluginMutex.Unlock()
pluginMutex.RLock()
defer pluginMutex.RUnlock()

pb, found := pluginBuilders[name]
return pb, found
Expand Down Expand Up @@ -111,8 +111,8 @@ func RegisterAction(act Action) {

// GetAction get the action by name
func GetAction(name string) (Action, bool) {
pluginMutex.Lock()
defer pluginMutex.Unlock()
pluginMutex.RLock()
defer pluginMutex.RUnlock()

act, found := actionMap[name]
return act, found
Expand Down

0 comments on commit bf26553

Please sign in to comment.