NAME

EV::Bind - Easier Interface To EV's Callbacks

SYNOPSIS

use EV;
use EV::Watcher::Bind;

EV::io_bind($fh, $mask, $callback, @args);

DESCRIPTION

Highly experimental. You've been warned.

EV::Watcher::Bind provides a simple interface to EV.pm's watcher methods that allows you to bind arguments as well as the watcher being created to the callback being registerd.

If you have, for example, an object that you want to use as your callback, you always need to do

my $obj = ...;
my @args = (1, 2, 3);
my $io = EV::io($fh, $mask, sub { $obj->foo(@args) });

With EV::Watcher::Bind, you can do

my $io = EV::io_bind($fh, $mask, \&foo, $obj, @args);

The functions provided by EV::Watcher::Bind also has the advantage of passing you the EV::Watcher object that caused your callback to execute as the last argument in your callback. In the above example, foo() could have be implemented like so:

sub foo {
  my ($self, $arg1, $arg2, $arg3, $w) = @_;
  $w->stop;
}

METHODS

EV::Watcher::Bind provides the following functions:

EV::io_bind

EV::io_ns_bind

EV::timer_bind

EV::timer_ns_bind

EV::periodic_bind

EV::periodic_ns_bind

EV::signal_bind

EV::signal_ns_bind

EV::child_bind

EV::child_ns_bind

EV::idle_bind

EV::idle_ns_bind

EV::prepare_bind

EV::prepare_ns_bind

EV::check_bind

EV::check_ns_bind

AUTHOR

Copyright (c) 2007 Daisuke Maki <daisuke@endeworks.jp>

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html