Net::DBus::ASyncReply Methods
AN!Tools :: Net::DBus Binding Tutorial :: Net::DBus::ASyncReply Methods |
discard_result
Usage:
$asyncreply->discard_result;
This tells the program that the caller is no longer interested in any further responses. Once this is called, the associated object should no longer be used.
wait_for_result
Usage:
$asyncreply->wait_for_result;
This holds or pauses the caller until the remote method has returned results. Once this returns, you can collect the returned data using the 'get_result' method.
is_ready
Usage:
my $boolean = $asyncreply->is_ready;
- MADI: Would a good example of this be something like "while (!$asyncreply->is_ready) { &display_progress_bar; } # Where 'display_progress_bar' is some yet-written method..." ?
This returns a boolean value of (TRUE/0??) when the remote method has returned data or timed out. Once true, you can collect the data or error using the 'get_result' method.
set_notify
Usage:
my $coderef=\&some_method();
$asyncreply->set_notify($coderef);
This takes a reference to a method and executes it when the remote method has completed. The referenced method will be called with only a reference to this object.
- MADI: Confirm that I understand this right. If I do, ask Daniel if it would be reasonable/safe/possible to take an array of extra variables that could be passed to the referenced method. Ie:
Usage:
sub set_notify {
my $self = shift;
my $cb = shift;
my @vars = @_;
$self->{pending_call}->set_notify(sub
{
my $pending_call = shift;
&$cb($self, @vars);
});
}
Call with:
$asyncreply->set_notify($coderef, $conf, $foo, $bar);
get_result
Usage:
my @data = $asyncreply->get_result;
This returns the data from the remote method call. If the remote method call timed out, this method will throw an exception. This should only be called after the 'is_ready' method returns a true value or the 'wait_for_result' method has returned. Once this method is called, this object should no longer be used.
- MADI: In the case of an exception, could/should a program run this in an 'eval'?
Any questions, feedback, advice, complaints or meanderings are welcome. | |||
Alteeve's Niche! | Alteeve Enterprise Support | Community Support | |
© 2025 Alteeve. Intelligent Availability® is a registered trademark of Alteeve's Niche! Inc. 1997-2025 | |||
legal stuff: All info is provided "As-Is". Do not use anything here unless you are willing and able to take responsibility for your own actions. |