Skip to content

Commit

Permalink
Add lock(f, lock) docstring to lock. (#33796)
Browse files Browse the repository at this point in the history
Currently the `lock(l) do ; ... end` method is not documented, and so
is not discoverable.
  • Loading branch information
NHDaly authored and KristofferC committed Apr 11, 2020
1 parent e89a578 commit 5b40bfd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions base/lock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ function relockall(rl::ReentrantLock, n::Int)
return
end

"""
lock(f::Function, lock)
Acquire the `lock`, execute `f` with the `lock` held, and release the `lock` when `f`
returns. If the lock is already locked by a different task/thread, wait for it to become
available.
When this function returns, the `lock` has been released, so the caller should
not attempt to `unlock` it.
"""
function lock(f, l::AbstractLock)
lock(l)
try
Expand Down

0 comments on commit 5b40bfd

Please sign in to comment.