ZMQ::Raw::Loop::Promise - Promise class
version 0.23
A ZMQ::Raw::Loop::Promise represents a promise
WARNING: The API of this module is unstable and may change without warning (any change will be appropriately documented in the changelog).
use ZMQ::Raw; my $context = ZMQ::Raw::Context->new; my $loop = ZMQ::Raw::Loop->new ($context); my $promise = ZMQ::Raw::Loop::Promise->new ($loop); $promise->then (sub { my $promise = shift; print "Promise kept/broken: ", $promise->result, "\n"; } ); my $timer = ZMQ::Raw::Loop::Timer->new ( timer => ZMQ::Raw::Timer->new ($context, after => 100), on_timeout => sub { $promise->keep ('done'); } ); $loop->add ($timer); $loop->run();
Create a new promise.
Get the status of the promise. One of PLANNED, KEPT or BROKEN.
PLANNED
KEPT
BROKEN
Wait for the promise to be kept or broken.
Wait for the promise to be kept or broken, if its kept the result will be returned, otherwise throws the cause.
Get the reason why the promise was broken. This method will croak if the promise is still planned or has been kept.
Break the promise, setting the cause to $result.
$result
Keep the promise, setting its result to $result.
Schedule \&callback to be fired when the promise is either kept or broken. Returns a new ZMQ::Raw::Loop::Promise.
\&callback
ZMQ::Raw::Loop::Promise
The promise is still planned.
The promise has been kept.
The promise was broken.
Jacques Germishuys <jacquesg@striata.com>
Copyright 2017 Jacques Germishuys.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install ZMQ::Raw, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ZMQ::Raw
CPAN shell
perl -MCPAN -e shell install ZMQ::Raw
For more information on module installation, please visit the detailed CPAN module installation guide.