Skip to content

Narnach/future

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Future

Future implements the future concept from IO. A future is an object that you create now, but which only gets a usable value in the future. Think of asynchronous messaging and long-lasting method calls.

An example:

f = Future.new { sleep 5; 123}
puts f * 5 #=> 615

This future will take 5 seconds to run, then 123 is returned. The call to f.* will block until the future has a return value.

Another example:

f1 = Future.new { sleep 5; 10}
f2 = Future.new { sleep 3; 20}
f3 = Future.new { sleep 1; 30}
puts f3 + f2 + f1

Here it only takes 5 seconds to calculate the sum instead of the 9 it would take when done sequentially.

Recent changes

Version 0.2.1

  • Cleared up the docs a little

  • Futures can take arguments and pass them to their Thread

  • Docfix: fixed typo

Version 0.2.0

  • Replaced Future Module with Future class. The old syntax is no longer supported.

  • Replaced one-time use of eval with undef_method.

Version 0.1.1

  • Added specs

Version 0.1.0

  • Created project

  • Added first version of future.rb, wrapped in a Module

  • Added documentation

Installation

From git

From the project root, use rake to install.

git clone http://github.com/Narnach/future
cd future
rake install

This will build the gem and install it for you.

About

future was created by Wes Oldenbeuving. It is licensed under the MIT license.

About

A naieve implementation of IO's future concept

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages