Skip to content

Commit

Permalink
Nothing -> NotGiven in scheduler.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
carstenbauer committed Mar 12, 2024
1 parent 70b42ce commit 33bb0e6
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/schedulers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct NotGiven end
isgiven(::NotGiven) = false
isgiven(::T) where {T} = true

const MaybeInteger = Union{Integer, Nothing}
const MaybeInteger = Union{Integer, NotGiven}

"""
Supertype for all available schedulers:
Expand Down Expand Up @@ -95,26 +95,26 @@ end

function DynamicScheduler(;
threadpool::Symbol = :default,
nchunks::MaybeInteger = nothing,
ntasks::MaybeInteger = nothing, # "alias" for nchunks
chunksize::MaybeInteger = nothing,
nchunks::MaybeInteger = NotGiven(),
ntasks::MaybeInteger = NotGiven(), # "alias" for nchunks
chunksize::MaybeInteger = NotGiven(),
chunking::Bool = true,
split::Symbol = :batch)
if !chunking
nchunks = -1
chunksize = -1
else
# only choose nchunks default if chunksize hasn't been specified
if isnothing(nchunks) && isnothing(chunksize) && isnothing(ntasks)
if !isgiven(nchunks) && !isgiven(chunksize) && !isgiven(ntasks)
nchunks = 2 * nthreads(threadpool)
chunksize = -1
else
if !isnothing(nchunks) && !isnothing(ntasks)
if isgiven(nchunks) && isgiven(ntasks)
throw(ArgumentError("nchunks and ntasks are aliases and only one may be provided"))
end
nchunks = !isnothing(nchunks) ? nchunks :
!isnothing(ntasks) ? ntasks : -1
chunksize = isnothing(chunksize) ? -1 : chunksize
nchunks = isgiven(nchunks) ? nchunks :
isgiven(ntasks) ? ntasks : -1
chunksize = isgiven(chunksize) ? chunksize : -1
end
end
DynamicScheduler(threadpool, nchunks, chunksize, split; chunking)
Expand Down Expand Up @@ -179,26 +179,26 @@ struct StaticScheduler{C <: ChunkingMode} <: Scheduler
end

function StaticScheduler(;
nchunks::MaybeInteger = nothing,
ntasks::MaybeInteger = nothing, # "alias" for nchunks
chunksize::MaybeInteger = nothing,
nchunks::MaybeInteger = NotGiven(),
ntasks::MaybeInteger = NotGiven(), # "alias" for nchunks
chunksize::MaybeInteger = NotGiven(),
chunking::Bool = true,
split::Symbol = :batch)
if !chunking
nchunks = -1
chunksize = -1
else
# only choose nchunks default if chunksize hasn't been specified
if isnothing(nchunks) && isnothing(chunksize) && isnothing(ntasks)
if !isgiven(nchunks) && !isgiven(chunksize) && !isgiven(ntasks)
nchunks = nthreads(:default)
chunksize = -1
else
if !isnothing(nchunks) && !isnothing(ntasks)
if isgiven(nchunks) && isgiven(ntasks)
throw(ArgumentError("nchunks and ntasks are aliases and only one may be provided"))
end
nchunks = !isnothing(nchunks) ? nchunks :
!isnothing(ntasks) ? ntasks : -1
chunksize = isnothing(chunksize) ? -1 : chunksize
nchunks = isgiven(nchunks) ? nchunks :
isgiven(ntasks) ? ntasks : -1
chunksize = isgiven(chunksize) ? chunksize : -1
end
end
StaticScheduler(nchunks, chunksize, split; chunking)
Expand Down

0 comments on commit 33bb0e6

Please sign in to comment.