-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Libdl: Add documentation for LazyLibrary and friends #59841
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
Conversation
Adds documentation for `Libdl.LazyLibrary` and related types. Also extends the C calling manual with an expanded section on using `LazyLibrary` for lazy library loading, including practical examples of platform-specific libraries, dependency management, lazy path construction, and initialization callbacks. Remove a few oddly confusing or incorrect notes as well. Also fix a `copy` oddly implemented as `convert(Vector{LazyLibrary}, convert(Vector{Any}, LazyLibrary[]))` from #59233 to just call `copy`. 🤖 Generated with help by Claude Code.
ca5b4a3
to
5401459
Compare
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.
Thanks, looks good to me!
The dlopen operation is thread-safe: only one thread loads the library, acquired after the | ||
release store of the reference to each dependency from loading of each dependency. Other | ||
tasks block until loading completes. The handle is then cached and reused for all subsequent |
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.
When you say other tasks, you mean other dlopen()
tasks, right? Not all tasks?
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.
Yes, I guess we should clarify that it is only of this specific library (e.g. so that doing dlopen in parallel is not UB for deadlocks)
|
||
#### Lazy Path Construction | ||
|
||
For libraries whose paths are determined at runtime, use `LazyLibraryPath`: |
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.
Maybe make a small note as to why you didn't need to use LazyLibraryPath
when doing the OS-specific paths above.
For more details, see the [`Libdl.LazyLibrary`](@ref) documentation. | ||
### Overloading `dlopen` for Custom Types |
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.
What is this section for? Are you trying to warn other people who might overload dlopen()
(like we did for LazyLibrary
) or are you saying there's some reason someone might want to overload dlopen()
for LazyLibrary
itself?
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.
You can write your own LazyLibrary-like types. This is documentation for those fools who write LazyLibrary types, like us.
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.
Nice; maybe say that LazyLibrary
is one such type, since I was a little confused at first, thinking this was further useful information under the LazyLibrary
umbrella.
Thanks for this Jameson, it's really nicely put together. |
Adds documentation for
Libdl.LazyLibrary
and related types.Also extends the C calling manual with an expanded section on using
LazyLibrary
for lazy library loading, including practical examples of platform-specific libraries, dependency management, lazy path construction, and initialization callbacks. Remove a few oddly confusing or incorrect notes as well.Also fix a
copy
oddly implemented asconvert(Vector{LazyLibrary}, convert(Vector{Any}, LazyLibrary[]))
from #59233 to just callcopy
.🤖 Generated with help by Claude Code.