rename sharedcalls to singleflight (#1017)
This commit is contained in:
@@ -9,16 +9,16 @@ import (
|
||||
|
||||
// A ResourceManager is a manager that used to manage resources.
|
||||
type ResourceManager struct {
|
||||
resources map[string]io.Closer
|
||||
sharedCalls SharedCalls
|
||||
lock sync.RWMutex
|
||||
resources map[string]io.Closer
|
||||
singleFlight SingleFlight
|
||||
lock sync.RWMutex
|
||||
}
|
||||
|
||||
// NewResourceManager returns a ResourceManager.
|
||||
func NewResourceManager() *ResourceManager {
|
||||
return &ResourceManager{
|
||||
resources: make(map[string]io.Closer),
|
||||
sharedCalls: NewSharedCalls(),
|
||||
resources: make(map[string]io.Closer),
|
||||
singleFlight: NewSingleFlight(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func (manager *ResourceManager) Close() error {
|
||||
|
||||
// GetResource returns the resource associated with given key.
|
||||
func (manager *ResourceManager) GetResource(key string, create func() (io.Closer, error)) (io.Closer, error) {
|
||||
val, err := manager.sharedCalls.Do(key, func() (interface{}, error) {
|
||||
val, err := manager.singleFlight.Do(key, func() (interface{}, error) {
|
||||
manager.lock.RLock()
|
||||
resource, ok := manager.resources[key]
|
||||
manager.lock.RUnlock()
|
||||
|
||||
Reference in New Issue
Block a user