From 8eb10a58ad7401241aa29db0da8aede7a1b41cf2 Mon Sep 17 00:00:00 2001 From: hailaz <739476267@qq.com> Date: Mon, 24 Jun 2019 17:15:30 +0800 Subject: [PATCH] Improve gflock. --- g/os/gflock/gflock.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/g/os/gflock/gflock.go b/g/os/gflock/gflock.go index e629720ca..5b0d3669c 100644 --- a/g/os/gflock/gflock.go +++ b/g/os/gflock/gflock.go @@ -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() }