Skip to content

Commit

Permalink
Fix the doc of Concurrent.available_processor_count
Browse files Browse the repository at this point in the history
Currently, the doc says that this methods returns `nil` if there is
no cpu_quota, but actually not.
https://github.com/ruby-concurrency/concurrent-ruby/blob/6f7c91ab5a4e99d850f69c958572a536426277e8/lib/concurrent-ruby/concurrent/utility/processor_counter.rb#L30

This PR fixes the doc to match the behavior.

Co-authored-by: Benoit Daloze <[email protected]>
  • Loading branch information
y-yagi and eregon committed Aug 9, 2024
1 parent 6f7c91a commit cbee215
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/concurrent-ruby/concurrent/utility/processor_counter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def compute_physical_processor_count
# Bail out if both commands returned something unexpected
processor_count
else
# powershell: "\nNumberOfCores\n-------------\n 4\n\n\n"
# powershell: "\nNumberOfCores\n-------------\n 4\n\n\n"
# wmic: "NumberOfCores \n\n4 \n\n\n\n"
result.scan(/\d+/).map(&:to_i).reduce(:+)
end
Expand Down Expand Up @@ -181,13 +181,14 @@ def self.physical_processor_count
end

# Number of processors cores available for process scheduling.
# Returns `nil` if there is no #cpu_quota, or a `Float` if the
# process is inside a cgroup with a dedicated CPU quota (typically Docker).
# This method takes in account the CPU quota if the process is inside a cgroup with a
# dedicated CPU quota (typically Docker).
# Otherwise it returns the same value as #processor_count but as a Float.
#
# For performance reasons the calculated value will be memoized on the first
# call.
#
# @return [nil, Float] number of available processors
# @return [Float] number of available processors
def self.available_processor_count
processor_counter.available_processor_count
end
Expand Down

0 comments on commit cbee215

Please sign in to comment.