-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Mention Base.Lockable in "multi-threading.md" #58107
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
base: master
Are you sure you want to change the base?
Mention Base.Lockable in "multi-threading.md" #58107
Conversation
When I originally learnt about multithreading and locks (and ended up rewriting [https://docs.julialang.org/en/v1/manual/multi-threading/#man-using-locks](Using locks to avoid data-races)), I was puzzled to find that the association of a lock and a value was the mental task of the programmer, and not the programmatic task of the program. I was therefore very happy to see Base.Lockable introduced in Julia 1.11. What was missing, was any mention of it in the relevant section of the manual. This PR adds a subsection under locks (So a forth level of headings, not sure if that is fine), showcasing and reccomending the use of Base.Lockable. I have made heavy use of comments in the example, which breaks with the general style, but adds valuable interpretation along the way. I am very open restructuring that part in particular.
how far back can this be backported? |
I am almost certain that Lockable was introduced in 1.11. |
Can confirm that _
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.11.4 (2025-03-10)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> Base.Lockable
Base.Lockable
julia>
dennis.bal ~ v3.12.10 08:09
julia +1.10
ERROR: `1.10` is not installed. Please run `juliaup add 1.10` to install channel or version.
dennis.bal ~ v3.12.10 08:09
juliaup add 1.10
Checking for new Julia versions
Installing Julia 1.10.9+0.x64.w64.mingw32
dennis.bal ~ v3.12.10 08:10
julia +1.10
Precompiling OhMyREPL finished.
8 dependencies successfully precompiled in 17 seconds
[ Info: OhMyREPL loaded
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.10.9 (2025-03-10)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> Base.Lockable
ERROR: UndefVarError: `Lockable` not defined
Stacktrace:
[1] getproperty(x::Module, f::Symbol)
@ Base .\Base.jl:31
[2] top-level scope
@ REPL[1]:1 |
Is this PR waiting for anything in particular? |
|
||
|
||
```julia-repl | ||
julia> my_array = []; # Simple empty array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments about this code block:
- I think it is overcommenting a bit. There is not really a need to comment on creating an empty array.
- The comments become quite long on a single line, which will require horizontal scrolling to read on the website.
I'd take some inspiration of how the section below is written, ideally the text before the code should be enough to understand the code.
When I originally learned about multithreading and locks (and ended up rewriting [https://docs.julialang.org/en/v1/manual/multi-threading/#man-using-locks](Using locks to avoid data-races)), I was puzzled to find that the association of a lock and a value was the mental task of the programmer, and not the programmatic task of the program. I made that explicit in that section of the manual, writing the following:
I was therefore very happy to see Base.Lockable introduced in Julia 1.11. What was missing, was any mention of it in the relevant section of the manual.
This PR adds a subsection under locks (So a forth level of headings, not sure if that is fine), showcasing and reccomending the use of Base.Lockable. I have made heavy use of comments in the example, which breaks with the general style, but adds valuable interpretation along the way. I am very open restructuring that part in particular.