Module: ZeevexConcurrency::ThreadPool

Defined in:
lib/zeevex_concurrency/thread_pool.rb

Defined Under Namespace

Modules: Stubs Classes: EventLoopAdapter, FixedPool, InlineThreadPool, ThreadPerJobPool

Class Method Summary collapse

Class Method Details

.cpu_countObject

Return the number of CPUs reported by the system



338
339
340
341
342
343
344
345
# File 'lib/zeevex_concurrency/thread_pool.rb', line 338

def self.cpu_count
  return Java::Java.lang.Runtime.getRuntime.availableProcessors if defined? Java::Java
  return File.read('/proc/cpuinfo').scan(/^processor\s*:/).size if File.exist? '/proc/cpuinfo'
  require 'win32ole'
  WIN32OLE.connect("winmgmts://").ExecQuery("select * from Win32_ComputerSystem").NumberOfProcessors
rescue LoadError
  Integer `sysctl -n hw.ncpu 2>/dev/null` rescue 1
end