@@ -66,7 +66,7 @@ read_lock_file(slf::SimpleLockFile) = _read_lock_file(lock_path(slf))
6666
6767_is_valid_ttag (ttag) = ttag > time ()
6868
69- function has_lock (lf:: String , lkid:: String )
69+ function is_locked (lf:: String , lkid:: String )
7070
7171 # read
7272 curr_lid, ttag = _read_lock_file (lf)
@@ -81,22 +81,22 @@ function has_lock(lf::String, lkid::String)
8181 return lkid == curr_lid
8282end
8383
84- has_lock (slf:: SimpleLockFile , lkid:: String ) = has_lock (lock_path (slf), lkid)
84+ is_locked (slf:: SimpleLockFile , lkid:: String ) = is_locked (lock_path (slf), lkid)
8585
8686# ----------------------------------------------------------------------
8787# release
8888
8989function release_lock (lf:: String , lkid:: String )
9090 ! isfile (lf) && return false
91- ! has_lock (lf, lkid) && return false
91+ ! is_locked (lf, lkid) && return false
9292 isfile (lf) && rm (lf; force = true )
9393 return true
9494end
9595
9696release_lock (slf:: SimpleLockFile , lkid:: String ) = release_lock (lock_path (slf), lkid)
9797
9898# ----------------------------------------------------------------------
99- # acquire
99+ # acquire_lock
100100
101101function _acquire (lf:: String , lkid:: String = rand_lkid ();
102102 vtime = _LOCK_DFT_VALID_TIME
@@ -120,7 +120,7 @@ function _acquire(lf::String, lkid::String = rand_lkid();
120120 return _write_lock_file (lf; lkid, vtime)
121121end
122122
123- function acquire (lf:: String , lkid:: String = rand_lkid ();
123+ function acquire_lock (lf:: String , lkid:: String = rand_lkid ();
124124 vtime = _LOCK_DFT_VALID_TIME,
125125 wt = _LOCK_DFT_WAIT_TIME,
126126 tout = _LOCK_DFT_TIME_OUT,
@@ -147,7 +147,7 @@ function acquire(lf::String, lkid::String = rand_lkid();
147147 end
148148end
149149
150- acquire (slf:: SimpleLockFile , lkid:: String = rand_lkid (); kwargs... ) = acquire (lock_path (slf), lkid)
150+ acquire_lock (slf:: SimpleLockFile , lkid:: String = rand_lkid (); kwargs... ) = acquire_lock (lock_path (slf), lkid)
151151
152152# ----------------------------------------------------------------------
153153# Base.lock
@@ -161,10 +161,10 @@ import Base.lock
161161 force = false
162162 )
163163
164- Acquire the lock, execute `f()` with the lock held, and release the lock when f returns.
164+ acquire_lock the lock, execute `f()` with the lock held, and release the lock when f returns.
165165If the lock is already locked by a different `lkid`, wait (till `tout`) for it to become available.
166- During waiting, it will sleep `wt` seconds before re-attemping to acquire .
167- If `force = true` it will acquire the lock after `tout`.
166+ During waiting, it will sleep `wt` seconds before re-attemping to acquire_lock .
167+ If `force = true` it will acquire_lock the lock after `tout`.
168168This method is not fully secure to race, but it must be ok for sllow applications.
169169Returns `true` if the lock
170170
@@ -179,10 +179,10 @@ function lock(
179179
180180 lf = lock_path (slf)
181181 try
182- acquire (lf, lkid; force, vtime, wt, tout)
182+ acquire_lock (lf, lkid; force, vtime, wt, tout)
183183 f ()
184184 finally
185- ok_flag = has_lock (lf, lkid)
185+ ok_flag = is_locked (lf, lkid)
186186 release_lock (lf, lkid)
187187 return ok_flag
188188 end
0 commit comments