NAME

Sub::Future - concurrency with futures

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 (blocking if necessary)
print "Long computation returned: $value\n";

Exported Subroutines

future $coderef

Starts executing $coderef in parallel and then 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.

SUPPORT

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

perldoc Sub::Future

See Also

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

COPYRIGHT & LICENSE

Copyright 2009 Michael Hendricks, all rights reserved.

This program is released under the following license: mit