our @EXPORT = qw(future await_future await_all);
-sub _log { printf "[%s] %s\n", scalar(localtime), join '', @_ }
-
sub future (&;$) {
my $f = $_[0]->(CPS::Future->new);
return $f if ((caller(1+($_[1]||0))||'') eq 'start');
sub await_future {
my $f = shift;
- _log(sprintf "got $f: [%s]", $f->is_ready);
return $f if $f->is_ready;
require Object::Remote;
my $loop = Object::Remote->current_loop;
has _timers => (is => 'ro', default => sub { [] });
-sub _log { shift; printf "[%s] %s\n", scalar(localtime), join '', @_ }
-
sub pass_watches_to {
my ($self, $new_loop) = @_;
foreach my $fh ($self->_read_select->handles) {
# differentiate between an error and a timeout.
# -- no, love, mst.
foreach my $fh (@$readable) {
- $self->_log("got a readable: $fh");
$read->{$fh}() if $read->{$fh};
}
foreach my $fh (@$writeable) {
has _receive_data_buffer => (is => 'ro', default => sub { my $x = ''; \$x });
+sub _log { shift; printf "[%s] %s\n", scalar(localtime), join '', @_ }
+
sub _receive_data_from {
my ($self, $fh) = @_;
my $rb = $self->_receive_data_buffer;
on_read_ready => 1
);
$self->on_close_call->($err);
+ $self->_log(sprintf "!!!!!Closing %s due to $err!!!!!\n\n\n\n\n", $self->fh);
}
}