blib/lib/AnyEvent/Impl/Irssi.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 28 CC 2 SCAR 12.0
CC
2
Cov
0%
init
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.3
1 =head1 NAME
2  
3 AnyEvent::Impl::Irssi - AnyEvent adaptor for Irssi
4  
5 =head1 SYNOPSIS
6  
7 use AnyEvent;
8
9 # this module gets loaded automatically when running under irssi
10  
11 =head1 DESCRIPTION
12  
13 This module provides transparent support for AnyEvent. You don't have to
14 do anything to make Irssi scripts work with AnyEvent.
15  
16 Limitations of this backend and implementation details:
17  
18 =over 4
19  
20 =item * This backend does not support blocking waits.
21  
22 That means you must set a callback on any condvars, or otherwise make sure
23 to never call C<recv> on a condvar that hasn't been signalled yet.
24  
25 =item * Child exits will be handled by AnyEvent.
26  
27 AnyEvent will take over child handling, as Irssi only polls for children
28 once/second and cannot handle unspecific child watchers.
29  
30 This I<should> have no negative effect, as AnyEvent will emit a pidwait
31 signal just like irssi itself would.
32  
33 =item * Artificial timer delays.
34  
35 Irssi artificially enforces timers to have at least a 10ms delay.
36  
37 This means that some applications will be limited to a rate of 100Hz (for
38 example, L<Coro::AnyEvent> thread scheduling).
39  
40 =item * Irssi leaks memory like hell.
41  
42 Yeah.
43  
44 =back
45  
46 Apart from that, documentation is notoriously wrong (e.g. file handles
47 are not supported by C<input_add>, contrary to documentation), hooking
48 into irssi has to be done in... weird... ways, but otherwise, Irssi is
49 surprisingly full-featured (for basically being a hack).
50  
51 =cut
52  
53 package AnyEvent::Impl::Irssi;
54  
55 use AnyEvent (); BEGIN { AnyEvent::common_sense }
56 use Carp ();
57 use Irssi ();
58  
59 our @ISA;
60  
61 # irssi works only from certain namespaces, so we
62 # create one and use it.
63 sub init {
64 my $pkg = caller;
65  
66 push @ISA, $pkg;
67  
68 local $/;
69 eval "package $pkg; " . <DATA>;
70 print "AnyEvent::Impl::Irssi fatal compilation error: $@" if $@;
71  
72 close DATA;
73 }
74  
75 Irssi::command "/script exec -permanent AnyEvent::Impl::Irssi::init 'AnyEvent adaptor'";
76  
77 1;
78  
79 __DATA__