| 1 | package Web::Dash::Util; | ||
| 2 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use Future::Q; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 0 | ▶ | use Net::DBus; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 6 | use Net::DBus::Annotation qw(dbus_call_async); | ||
| 7 | use Try::Tiny; | ||
| 8 | use Exporter qw(import); | ||
| 9 | |||
| 10 | our $VERSION = "0.041"; | ||
| 11 | |||
| 12 | our @EXPORT_OK = qw(future_dbus_call); | ||
| 13 | |||
| 14 | sub future_dbus_call { | ||
| 15 | my ($dbus_object, $method, @args) = @_; | ||
| 16 | return Future::Q->try(sub { | ||
| 17 | my $future = Future::Q->new; | ||
| 18 | $dbus_object->$method(dbus_call_async, @args)->set_notify(sub { | ||
| 19 | my $reply = shift; | ||
| 20 | try { | ||
| 21 | $future->fulfill($reply->get_result); | ||
| 22 | }catch { | ||
| 23 | my $e = shift; | ||
| 24 | $future->reject($e); | ||
| 25 | }; | ||
| 26 | }); | ||
| 27 | return $future; | ||
| 28 | }); | ||
| 29 | } | ||
| 30 | |||
| 31 | |||
| 32 | 1; | ||