Skip to content

Commit

Permalink
Hide internal classes from public docs
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Jan 23, 2023
1 parent 99f837a commit 11da3fe
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 35 deletions.
2 changes: 2 additions & 0 deletions lib/concurrent-ruby/concurrent/re_include.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ module Concurrent
#
# C1.new.respond_to? :a # => false
# C2.new.respond_to? :a # => true
#
# @!visibility private
module ReInclude
# @!visibility private
def included(base)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'concurrent/synchronization/abstract_lockable_object'

module Concurrent
# noinspection RubyInstanceVariableNamingConvention
module Synchronization

# @!visibility private
Expand Down
1 change: 1 addition & 0 deletions lib/concurrent-ruby/concurrent/synchronization/object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Synchronization
# - final instance variables see {Object.safe_initialization!}
# - volatile instance variables see {Object.attr_volatile}
# - volatile instance variables see {Object.attr_atomic}
# @!visibility private
class Object < AbstractObject
include Volatile

Expand Down
3 changes: 2 additions & 1 deletion lib/concurrent-ruby/concurrent/synchronization/volatile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ module Synchronization
# => 1
# foo.bar = 2
# => 2

#
# @!visibility private
module Volatile
def self.included(base)
base.extend(ClassMethods)
Expand Down
1 change: 1 addition & 0 deletions lib/concurrent-ruby/concurrent/tvar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def leave_transaction

private

# @!visibility private
class Transaction

ABORTED = ::Object.new
Expand Down
1 change: 1 addition & 0 deletions lib/concurrent-ruby/concurrent/utility/engine.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module Concurrent
# @!visibility private
module Utility

# @!visibility private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'concurrent/synchronization/abstract_object'

module Concurrent
# @!visibility private
module Utility
# @!visibility private
module NativeExtensionLoader
Expand Down
1 change: 1 addition & 0 deletions lib/concurrent-ruby/concurrent/utility/native_integer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module Concurrent
# @!visibility private
module Utility
# @private
module NativeInteger
Expand Down
67 changes: 34 additions & 33 deletions lib/concurrent-ruby/concurrent/utility/processor_counter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'concurrent/delay'

module Concurrent
# @!visibility private
module Utility

# @!visibility private
Expand All @@ -12,43 +13,10 @@ def initialize
@physical_processor_count = Delay.new { compute_physical_processor_count }
end

# Number of processors seen by the OS and used for process scheduling. For
# performance reasons the calculated value will be memoized on the first
# call.
#
# When running under JRuby the Java runtime call
# `java.lang.Runtime.getRuntime.availableProcessors` will be used. According
# to the Java documentation this "value may change during a particular
# invocation of the virtual machine... [applications] should therefore
# occasionally poll this property." Subsequently the result will NOT be
# memoized under JRuby.
#
# Otherwise Ruby's Etc.nprocessors will be used.
#
# @return [Integer] number of processors seen by the OS or Java runtime
#
# @see http://docs.oracle.com/javase/6/docs/api/java/lang/Runtime.html#availableProcessors()
def processor_count
@processor_count.value
end

# Number of physical processor cores on the current system. For performance
# reasons the calculated value will be memoized on the first call.
#
# On Windows the Win32 API will be queried for the `NumberOfCores from
# Win32_Processor`. This will return the total number "of cores for the
# current instance of the processor." On Unix-like operating systems either
# the `hwprefs` or `sysctl` utility will be called in a subshell and the
# returned value will be used. In the rare case where none of these methods
# work or an exception is raised the function will simply return 1.
#
# @return [Integer] number physical processor cores on the current system
#
# @see https://github.com/grosser/parallel/blob/4fc8b89d08c7091fe0419ca8fba1ec3ce5a8d185/lib/parallel.rb
#
# @see http://msdn.microsoft.com/en-us/library/aa394373(v=vs.85).aspx
# @see http://www.unix.com/man-page/osx/1/HWPREFS/
# @see http://linux.die.net/man/8/sysctl
def physical_processor_count
@physical_processor_count.value
end
Expand Down Expand Up @@ -99,10 +67,43 @@ def compute_physical_processor_count
@processor_counter = Utility::ProcessorCounter.new
singleton_class.send :attr_reader, :processor_counter

# Number of processors seen by the OS and used for process scheduling. For
# performance reasons the calculated value will be memoized on the first
# call.
#
# When running under JRuby the Java runtime call
# `java.lang.Runtime.getRuntime.availableProcessors` will be used. According
# to the Java documentation this "value may change during a particular
# invocation of the virtual machine... [applications] should therefore
# occasionally poll this property." Subsequently the result will NOT be
# memoized under JRuby.
#
# Otherwise Ruby's Etc.nprocessors will be used.
#
# @return [Integer] number of processors seen by the OS or Java runtime
#
# @see http://docs.oracle.com/javase/6/docs/api/java/lang/Runtime.html#availableProcessors()
def self.processor_count
processor_counter.processor_count
end

# Number of physical processor cores on the current system. For performance
# reasons the calculated value will be memoized on the first call.
#
# On Windows the Win32 API will be queried for the `NumberOfCores from
# Win32_Processor`. This will return the total number "of cores for the
# current instance of the processor." On Unix-like operating systems either
# the `hwprefs` or `sysctl` utility will be called in a subshell and the
# returned value will be used. In the rare case where none of these methods
# work or an exception is raised the function will simply return 1.
#
# @return [Integer] number physical processor cores on the current system
#
# @see https://github.com/grosser/parallel/blob/4fc8b89d08c7091fe0419ca8fba1ec3ce5a8d185/lib/parallel.rb
#
# @see http://msdn.microsoft.com/en-us/library/aa394373(v=vs.85).aspx
# @see http://www.unix.com/man-page/osx/1/HWPREFS/
# @see http://linux.die.net/man/8/sysctl
def self.physical_processor_count
processor_counter.physical_processor_count
end
Expand Down

0 comments on commit 11da3fe

Please sign in to comment.