-
Notifications
You must be signed in to change notification settings - Fork 1.5k
refactor: replace OnceLock
with LazyLock
#13641
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
// TODO: Use LazyLock instead of getter function when MSRV gets bumped | ||
static $name: OnceLock<LogicalTypeRef> = OnceLock::new(); | ||
static $name: LazyLock<LogicalTypeRef> = | ||
LazyLock::new(|| Arc::new(NativeType::$ty)); | ||
|
||
#[doc = "Getter for singleton instance of a logical type representing"] | ||
#[doc = concat!("[`NativeType::", stringify!($ty), "`].")] | ||
pub fn $getter() -> LogicalTypeRef { |
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.
Current callers require a LogicalTypeRef
, so this getter still seems to be needed.
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 @jonahgao
THere appear to be quite a few more uses of OnceLock in th code too:
https://github.com/search?q=repo%3Aapache%2Fdatafusion+OnceLock&type=code
Do you plan on moving them too?
I also linked this PR to #11687 which has a few other PRs linked as well that were in draft
Thats good point, wondering we probably want to use LazyLock in documentation generation |
* refactor: Replace OnceLock with LazyLock * Fix typo
Which issue does this PR close?
Part of #11687
Clear the TODOs after updating MSRV to 1.80.
Rationale for this change
LazyLock
has been stable since Rust version 1.80.0, and it provides a simpler and more suitable way to define static variables.What changes are included in this PR?
Are these changes tested?
Yes. By existing tests.
Are there any user-facing changes?
No