parallel 1.11.2 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/parallel.rb +2 -2
- data/lib/parallel/processor_count.rb +37 -29
- data/lib/parallel/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d516b382495f15f9f39f2e7e70b45f9e8cc7990
|
4
|
+
data.tar.gz: f69e6276501cd7c8a11c19531dc9d213e5fb8661
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97d543d959430f47a9d98a352a4c241584eaba9ef60d921dd64a4c2f4d1f9c77b54eb54bb52623a71e33f73e1a2d2e2b3dd9be1a9cef0036b320113bb1ef9bce
|
7
|
+
data.tar.gz: 7885aabe97131a2722952ee77fa15c4cc3f7df0034d44fd104cc796f27be73dd09806b5c9860dd057522d602dc1b08949b37e88ebd5f5be32f4987208957c8fa
|
data/lib/parallel.rb
CHANGED
@@ -219,12 +219,12 @@ module Parallel
|
|
219
219
|
|
220
220
|
def any?(*args, &block)
|
221
221
|
raise "You must provide a block when calling #any?" if block.nil?
|
222
|
-
!each(*args) { |*
|
222
|
+
!each(*args) { |*a| raise Parallel::Kill if block.call(*a) }
|
223
223
|
end
|
224
224
|
|
225
225
|
def all?(*args, &block)
|
226
226
|
raise "You must provide a block when calling #all?" if block.nil?
|
227
|
-
!!each(*args) { |*
|
227
|
+
!!each(*args) { |*a| raise Parallel::Kill unless block.call(*a) }
|
228
228
|
end
|
229
229
|
|
230
230
|
def each_with_index(array, options={}, &block)
|
@@ -1,3 +1,7 @@
|
|
1
|
+
if RUBY_VERSION.to_f >= 2.2
|
2
|
+
require 'etc'
|
3
|
+
end
|
4
|
+
|
1
5
|
module Parallel
|
2
6
|
module ProcessorCount
|
3
7
|
# Number of processors seen by the OS and used for process scheduling.
|
@@ -16,36 +20,40 @@ module Parallel
|
|
16
20
|
#
|
17
21
|
def processor_count
|
18
22
|
@processor_count ||= begin
|
19
|
-
|
20
|
-
|
21
|
-
require 'win32ole'
|
22
|
-
result = WIN32OLE.connect("winmgmts://").ExecQuery(
|
23
|
-
"select NumberOfLogicalProcessors from Win32_Processor")
|
24
|
-
result.to_enum.collect(&:NumberOfLogicalProcessors).reduce(:+)
|
25
|
-
elsif File.readable?("/proc/cpuinfo")
|
26
|
-
IO.read("/proc/cpuinfo").scan(/^processor/).size
|
27
|
-
elsif File.executable?("/usr/bin/hwprefs")
|
28
|
-
IO.popen("/usr/bin/hwprefs thread_count").read.to_i
|
29
|
-
elsif File.executable?("/usr/sbin/psrinfo")
|
30
|
-
IO.popen("/usr/sbin/psrinfo").read.scan(/^.*on-*line/).size
|
31
|
-
elsif File.executable?("/usr/sbin/ioscan")
|
32
|
-
IO.popen("/usr/sbin/ioscan -kC processor") do |out|
|
33
|
-
out.read.scan(/^.*processor/).size
|
34
|
-
end
|
35
|
-
elsif File.executable?("/usr/sbin/pmcycles")
|
36
|
-
IO.popen("/usr/sbin/pmcycles -m").read.count("\n")
|
37
|
-
elsif File.executable?("/usr/sbin/lsdev")
|
38
|
-
IO.popen("/usr/sbin/lsdev -Cc processor -S 1").read.count("\n")
|
39
|
-
elsif File.executable?("/usr/sbin/sysconf") and os_name =~ /irix/i
|
40
|
-
IO.popen("/usr/sbin/sysconf NPROC_ONLN").read.to_i
|
41
|
-
elsif File.executable?("/usr/sbin/sysctl")
|
42
|
-
IO.popen("/usr/sbin/sysctl -n hw.ncpu").read.to_i
|
43
|
-
elsif File.executable?("/sbin/sysctl")
|
44
|
-
IO.popen("/sbin/sysctl -n hw.ncpu").read.to_i
|
23
|
+
if defined?(Etc) && Etc.respond_to?(:nprocessors)
|
24
|
+
Etc.nprocessors
|
45
25
|
else
|
46
|
-
|
47
|
-
|
48
|
-
|
26
|
+
os_name = RbConfig::CONFIG["target_os"]
|
27
|
+
if os_name =~ /mingw|mswin/
|
28
|
+
require 'win32ole'
|
29
|
+
result = WIN32OLE.connect("winmgmts://").ExecQuery(
|
30
|
+
"select NumberOfLogicalProcessors from Win32_Processor")
|
31
|
+
result.to_enum.collect(&:NumberOfLogicalProcessors).reduce(:+)
|
32
|
+
elsif File.readable?("/proc/cpuinfo")
|
33
|
+
IO.read("/proc/cpuinfo").scan(/^processor/).size
|
34
|
+
elsif File.executable?("/usr/bin/hwprefs")
|
35
|
+
IO.popen("/usr/bin/hwprefs thread_count").read.to_i
|
36
|
+
elsif File.executable?("/usr/sbin/psrinfo")
|
37
|
+
IO.popen("/usr/sbin/psrinfo").read.scan(/^.*on-*line/).size
|
38
|
+
elsif File.executable?("/usr/sbin/ioscan")
|
39
|
+
IO.popen("/usr/sbin/ioscan -kC processor") do |out|
|
40
|
+
out.read.scan(/^.*processor/).size
|
41
|
+
end
|
42
|
+
elsif File.executable?("/usr/sbin/pmcycles")
|
43
|
+
IO.popen("/usr/sbin/pmcycles -m").read.count("\n")
|
44
|
+
elsif File.executable?("/usr/sbin/lsdev")
|
45
|
+
IO.popen("/usr/sbin/lsdev -Cc processor -S 1").read.count("\n")
|
46
|
+
elsif File.executable?("/usr/sbin/sysconf") and os_name =~ /irix/i
|
47
|
+
IO.popen("/usr/sbin/sysconf NPROC_ONLN").read.to_i
|
48
|
+
elsif File.executable?("/usr/sbin/sysctl")
|
49
|
+
IO.popen("/usr/sbin/sysctl -n hw.ncpu").read.to_i
|
50
|
+
elsif File.executable?("/sbin/sysctl")
|
51
|
+
IO.popen("/sbin/sysctl -n hw.ncpu").read.to_i
|
52
|
+
else
|
53
|
+
$stderr.puts "Unknown platform: " + RbConfig::CONFIG["target_os"]
|
54
|
+
$stderr.puts "Assuming 1 processor."
|
55
|
+
1
|
56
|
+
end
|
49
57
|
end
|
50
58
|
end
|
51
59
|
end
|
data/lib/parallel/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: michael@grosser.it
|