Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lock(f, lock) docstring to lock. #33796

Merged
merged 1 commit into from
Nov 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add lock(f, lock) docstring to lock.
Currently the `lock(l) do ; ... end` method is not documented, and so
is not discoverable.
  • Loading branch information
NHDaly committed Nov 8, 2019
commit 310daa9db05b679949685769bb6a87ddb25fdaa7
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