source: perl/lib/BarnOwl/AnyEvent.pm @ 0b20de4

release-1.8release-1.9
Last change on this file since 0b20de4 was 0b20de4, checked in by Nelson Elhage <nelhage@nelhage.com>, 11 years ago
First pass at AnyEvent. Implementing io and timer. Not implementing child or idle.
  • Property mode set to 100644
File size: 731 bytes
Line 
1use strict;
2use warnings;
3package BarnOwl::AnyEvent;
4use BarnOwl::Timer;
5
6sub io {
7    my ($class, %arg) = @_;
8    my $fd = fileno($arg{fh});
9    my $mode = $arg{poll};
10    my $cb = $arg{cb};
11    my $self = {cb => $cb,
12                mode => $mode,
13                fd => $fd };
14    bless($self, class);
15    $self->{dispatch} = BarnOwl::add_io_dispatch($fd, $mode, $cb);
16    return $self;
17}
18
19sub BarnOwl::AnyEvent::io::DESTROY
20{
21    my ($self) = @_;
22    BarnOwl::remove_io_dispatch($self->{fd});
23}
24
25sub timer {
26    my ($class, %arg) = @_;
27    return BarnOwl::Timer->new(%args);
28}
29
30# sub idle {
31#     my ($class, %arg) = @_;
32#     my $cb = $arg{cb};
33# }
34
35# sub child {
36#     my ($class, %arg) = @_;
37#     my $cb = $arg{cb};
38# }
39
401;
Note: See TracBrowser for help on using the repository browser.