Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

comp_tree

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

comp_tree

  • 1.1.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= CompTree

== Summary

A simple framework for automatic parallelism.

== Synopsis

require 'comp_tree'

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

== Install

% gem install comp_tree

Or from inside an unpacked .tgz download, rake install / rake uninstall.

== Description

CompTree is a parallel computation tree structure based upon concepts from pure functional programming.

CompTree has been tested on MRI versions 1.8.6, 1.8.7, 1.9.1, 1.9.2, and jruby versions 1.4, 1.5, 1.6.

== Links

  • Home: http://quix.github.com/comp_tree
  • Feature Requests, Bug Reports: http://github.com/quix/comp_tree/issues
  • Manual Download: http://github.com/quix/comp_tree/archives/master
  • Repository: http://github.com/quix/comp_tree

== Background

The user should have a basic understanding of functional programming (see for example http://en.wikipedia.org/wiki/Functional_programming) and the meaning of side effects.

Every function you define must explicitly depend on the data it uses.

BAD example: depending on state -- offset not listed as a parameter

driver.define(:area, :width, :height) { |width, height| width*height - offset }

Unless offset is really a constant, the result of driver.compute(:area, n) is not well-defined for n > 1.

Just as depending on some changeable state is bad, it is likewise bad to affect a state (to produce a side effect).

BAD example: affecting state

driver.define(:area, :width, :height) { |width, height| accumulator.add "more data" width*height }

Given a tree where nodes are modifying accumulator, the end state of accumulator is not well-defined, even if accumulator is a thread-safe object.

Note however it is OK affect a state as long as no other function depends on that state. This is the principle under which CompTree parallelizes Rake tasks (http://drake.rubyforge.org).

== Author

== License

Copyright (c) 2008-2011 James M. Lawrence. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

FAQs

Package last updated on 18 May 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc