Improve gflock.

This commit is contained in:
hailaz
2019-06-24 17:15:30 +08:00
parent 9985378062
commit 8eb10a58ad

View File

@ -41,6 +41,11 @@ func (l *Locker) IsLocked() bool {
return l.flock.Locked()
}
// IsRLocked returns whether the locker is rlocked.
func (l *Locker) IsRLocked() bool {
return l.flock.RLocked()
}
// TryLock tries get the writing lock of the locker.
// It returns true if success, or else returns false immediately.
func (l *Locker) TryLock() bool {
@ -82,7 +87,7 @@ func (l *Locker) Lock() (err error) {
// Please note, if your shared lock became an exclusive lock this may
// unintentionally drop the exclusive lock if called by the consumer that
// believes they have a shared lock. Please see Lock() for more details.
func (l *Locker) UnLock() (err error) {
func (l *Locker) Unlock() (err error) {
return l.flock.Unlock()
}