ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-MP/bin/aemp
(Generate patch)

Comparing AnyEvent-MP/bin/aemp (file contents):
Revision 1.19 by root, Sun Aug 30 09:24:09 2009 UTC vs.
Revision 1.20 by root, Sun Aug 30 13:22:46 2009 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2
3
4# very stupid leak checker, checks after some time whether the passed
5# object is still around and tracks it via Devel::FindRef.
6sub leakcheck($$) {#d#
7 my ($after, $ref) = @_;
8
9use EV;#d#
10 Scalar::Util::weaken $ref;
11
12 my $w; $w = EV::timer $after, 0, sub {
13 undef $w;
14 return unless $ref;
15
16 require Devel::FindRef;
17 warn "object $ref still alive after $after seconds:\n"
18 . Devel::FindRef::track ($ref, 30);
19 };
20}
2 21
3=head1 NAME 22=head1 NAME
4 23
5 aemp - AnyEvent:MP utility 24 aemp - AnyEvent:MP utility
6 25
70 89
71use common::sense; 90use common::sense;
72 91
73# should come before anything else, so all modules 92# should come before anything else, so all modules
74# will be loaded on each restart 93# will be loaded on each restart
75BEGIN { 94#BEGIN {
76 if ($ARGV[0] eq "run") { 95 if ($ARGV[0] eq "run") {
77 shift; 96 shift;
78 97
79 # d'oh 98 # d'oh
80 require AnyEvent::Watchdog; 99# require AnyEvent::Watchdog;
81 # now we can load extra modules 100 # now we can load extra modules
82 101
83 AnyEvent::Watchdog::autorestart (1); 102# AnyEvent::Watchdog::autorestart (1);
84 AnyEvent::Watchdog::heartbeat (300); 103# AnyEvent::Watchdog::heartbeat (300);
85 104
86 require AnyEvent; 105 require AnyEvent;
87 require AnyEvent::MP; 106 require AnyEvent::MP;
88 AnyEvent::MP::initialise_node (@ARGV); 107 AnyEvent::MP::initialise_node (@ARGV);
89 108
90 AnyEvent::detect () eq "AnyEvent::Impl::EV" 109 AnyEvent::detect () eq "AnyEvent::Impl::EV"
91 ? EV::loop () 110 ? EV::loop ()
92 : AE::cv ()->recv; 111 : AE::cv ()->recv;
93 } 112 }
94} 113#}
95 114
96use Carp (); 115use Carp ();
97 116
98use JSON::XS; 117use JSON::XS;
99 118

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines