Class: Andromeda::Guides::PoolGuide
- Defined in:
- lib/andromeda/pool_guide.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#max_procs ⇒ Object
readonly
Returns the value of attribute max_procs.
-
#pool_track ⇒ Object
readonly
Returns the value of attribute pool_track.
Class Method Summary collapse
-
.num_procs ⇒ Fixnum
Number of processors as determined by Facter.
Instance Method Summary collapse
-
#initialize(num_procs = nil) ⇒ PoolGuide
constructor
A new instance of PoolGuide.
- #pack(plan, track, was_suggested = false) ⇒ Object
- #track(spot, label, suggested_track = nil) ⇒ Object
Methods inherited from Guide
Methods included from Impl::To_S
Constructor Details
#initialize(num_procs = nil) ⇒ PoolGuide
Returns a new instance of PoolGuide.
15 16 17 18 19 20 21 |
# File 'lib/andromeda/pool_guide.rb', line 15 def initialize(num_procs = nil) num_procs = PoolGuide.num_procs unless num_procs raise ArgumentError unless num_procs.is_a?(Fixnum) raise ArgumentError unless num_procs > 0 @max_procs = num_procs @pool_track = PoolTrack.new ThreadPool.new(@max_procs) end |
Instance Attribute Details
#max_procs ⇒ Object (readonly)
Returns the value of attribute max_procs.
6 7 8 |
# File 'lib/andromeda/pool_guide.rb', line 6 def max_procs @max_procs end |
#pool_track ⇒ Object (readonly)
Returns the value of attribute pool_track.
7 8 9 |
# File 'lib/andromeda/pool_guide.rb', line 7 def pool_track @pool_track end |
Class Method Details
.num_procs ⇒ Fixnum
Returns number of processors as determined by Facter.
10 11 12 13 |
# File 'lib/andromeda/pool_guide.rb', line 10 def self.num_procs @num_procs = Facter.sp_number_processors.strip.to_i unless defined?(@num_procs) @num_procs end |
Instance Method Details
#pack(plan, track, was_suggested = false) ⇒ Object
28 29 30 31 32 |
# File 'lib/andromeda/pool_guide.rb', line 28 def pack(plan, track, was_suggested = false) return plan if plan.frozen? return plan.identical_copy if was_suggested if max_procs > 1 then plan.identical_copy else plan end end |
#track(spot, label, suggested_track = nil) ⇒ Object
23 24 25 26 |
# File 'lib/andromeda/pool_guide.rb', line 23 def track(spot, label, suggested_track = nil) return suggested_track if suggested_track return @pool_track end |