Documentation ¶
Overview ¶
Package rwmutex provides switch of concurrent safety feature for sync.RWMutex.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RWMutex ¶
RWMutex is a sync.RWMutex with a switch for concurrent safe feature. If its attribute *sync.RWMutex is not nil, it means it's in concurrent safety usage. Its attribute *sync.RWMutex is nil in default, which makes this struct mush lightweight.
func Create ¶ added in v1.12.2
Create creates and returns a new RWMutex object. The parameter `safe` is used to specify whether using this mutex in concurrent safety, which is false in default.
func New ¶
New creates and returns a new *RWMutex. The parameter `safe` is used to specify whether using this mutex in concurrent safety, which is false in default.
func (*RWMutex) IsSafe ¶
IsSafe checks and returns whether current mutex is in concurrent-safe usage.
func (*RWMutex) Lock ¶
func (mu *RWMutex) Lock()
Lock locks mutex for writing. It does nothing if it is not in concurrent-safe usage.
func (*RWMutex) RLock ¶
func (mu *RWMutex) RLock()
RLock locks mutex for reading. It does nothing if it is not in concurrent-safe usage.