Skip to content

Make OncePerX subtype Function #57289

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

Merged
merged 1 commit into from
Feb 8, 2025
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
6 changes: 3 additions & 3 deletions base/lock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ julia> procstate === fetch(@async global_state())
true
```
"""
mutable struct OncePerProcess{T, F}
mutable struct OncePerProcess{T, F} <: Function
value::Union{Nothing,T}
@atomic state::UInt8 # 0=initial, 1=hasrun, 2=error
@atomic allow_compile_time::Bool
Expand Down Expand Up @@ -801,7 +801,7 @@ julia> threadvec === thread_state[Threads.threadid()]
true
```
"""
mutable struct OncePerThread{T, F}
mutable struct OncePerThread{T, F} <: Function
@atomic xs::AtomicMemory{T} # values
@atomic ss::AtomicMemory{UInt8} # states: 0=initial, 1=hasrun, 2=error, 3==concurrent
const initializer::F
Expand Down Expand Up @@ -926,7 +926,7 @@ Making lazy task value...done.
false
```
"""
mutable struct OncePerTask{T, F}
mutable struct OncePerTask{T, F} <: Function
const initializer::F

OncePerTask{T}(initializer::F) where {T, F} = new{T,F}(initializer)
Expand Down