NAME

Sub::Future - asynchronous programming with futures (or promises)

SYNOPSIS

use Sub::Future;
my $value = future {
    # long running computation goes here
    return 'result goes here';
};

# do some things that don't require $value
# while $value is calculated in parallel

# use the computation's return value (blocks if necessary)
print "Long computation returned: $value\n";

EXPORTED

future $coderef

Starts executing $coderef in parallel and returns immediately. The returned value can be used at any time to retrieve the value calculated by $coderef. If the parallel calculation isn't done, using the value blocks until the value is ready.

METHODS

value

Calling this method on the object returned by "future" returns the value calculated by the code block. It's usually not necessary to call this method directly since most operations performed on the object implicitly return the value.

AUTHOR

Michael Hendricks, <michael@ndrix.org>

BUGS

Please report any bugs or feature requests to bug-data-future at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sub-Future. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

VERSION CONTROL

git://github.com/mndrix/Sub-Future.git

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Sub::Future

SEE ALSO

http://github.com/mndrix/Sub-Future

http://en.wikipedia.org/wiki/Futures_and_promises

threads, forks, subs::parallel, Async

COPYRIGHT & LICENSE

Copyright 2009 Michael Hendricks, all rights reserved.

This program is released under the following license: mit