Skip to content

Commit cbee215

Browse files
y-yagieregon
andcommitted
Fix the doc of Concurrent.available_processor_count
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]>
1 parent 6f7c91a commit cbee215

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/concurrent-ruby/concurrent/utility/processor_counter.rb

+5-4
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def compute_physical_processor_count
8383
# Bail out if both commands returned something unexpected
8484
processor_count
8585
else
86-
# powershell: "\nNumberOfCores\n-------------\n 4\n\n\n"
86+
# powershell: "\nNumberOfCores\n-------------\n 4\n\n\n"
8787
# wmic: "NumberOfCores \n\n4 \n\n\n\n"
8888
result.scan(/\d+/).map(&:to_i).reduce(:+)
8989
end
@@ -181,13 +181,14 @@ def self.physical_processor_count
181181
end
182182

183183
# Number of processors cores available for process scheduling.
184-
# Returns `nil` if there is no #cpu_quota, or a `Float` if the
185-
# process is inside a cgroup with a dedicated CPU quota (typically Docker).
184+
# This method takes in account the CPU quota if the process is inside a cgroup with a
185+
# dedicated CPU quota (typically Docker).
186+
# Otherwise it returns the same value as #processor_count but as a Float.
186187
#
187188
# For performance reasons the calculated value will be memoized on the first
188189
# call.
189190
#
190-
# @return [nil, Float] number of available processors
191+
# @return [Float] number of available processors
191192
def self.available_processor_count
192193
processor_counter.available_processor_count
193194
end

0 commit comments

Comments
 (0)