CompTree — Parallel Computation Tree.
See README.rdoc.
Classes and Modules
- Driver
- Error
- NodeError
- RedefinitionError
- NoFunctionError
- NoNodeError
Public Class methods
build { |driver| ... }
Build a new computation tree. A Driver instance is passed to the given block.
Example:
CompTree.build do |driver| # Define a function named 'area' taking these two arguments. driver.define(:area, :width, :height) { |width, height| width*height } # Define a function 'width' which takes a 'border' argument. driver.define(:width, :border) { |border| 7 + border } # Ditto for 'height'. driver.define(:height, :border) { |border| 5 + border } # # Define a constant function 'border'. driver.define(:border) { 2 } # Compute the area using up to four parallel threads. puts driver.compute(:area, 4) # => 63 # We've done this computation. puts((7 + 2)*(5 + 2)) # => 63 end
A custom CompTree::Node subclass may optionally be provided,
CompTree.build(:node_class => MyNode) { ... }
This will build the tree with MyNode instances.
[show source]
# File lib/comp_tree.rb, line 84 84: def self.build(opts = {}) 85: yield Driver.new(opts) 86: end