1 |
root |
1.1 |
=head1 NAME |
2 |
|
|
|
3 |
|
|
AnyEvent::XSThreadPool - manage xs-level thread pools to do stuff asynchronously |
4 |
|
|
|
5 |
|
|
=head1 SYNOPSIS |
6 |
|
|
|
7 |
|
|
use AnyEvent::XSThreadPool; |
8 |
|
|
|
9 |
|
|
=head1 DESCRIPTION |
10 |
|
|
|
11 |
|
|
=over 4 |
12 |
|
|
|
13 |
|
|
=cut |
14 |
|
|
|
15 |
|
|
package AnyEvent::XSThreadPool; |
16 |
|
|
|
17 |
|
|
BEGIN { |
18 |
|
|
our $VERSION = 0.02; |
19 |
|
|
|
20 |
|
|
use XSLoader; |
21 |
|
|
XSLoader::load __PACKAGE__, $VERSION; |
22 |
|
|
} |
23 |
|
|
|
24 |
|
|
use AnyEvent; |
25 |
|
|
|
26 |
|
|
=item $pool = new AnyEvent::XSThreadPool |
27 |
|
|
|
28 |
|
|
=cut |
29 |
|
|
|
30 |
|
|
sub new { |
31 |
|
|
my ($class) = @_; |
32 |
|
|
|
33 |
|
|
my $self = bless [""], $class; |
34 |
|
|
|
35 |
|
|
my $poll_cb = _init $self->[0]; |
36 |
|
|
$self->[1] = AE::io $self->fileno, 0, $poll_cb; |
37 |
|
|
|
38 |
|
|
$self |
39 |
|
|
} |
40 |
|
|
|
41 |
|
|
sub DESTROY { |
42 |
|
|
&_destroy; |
43 |
|
|
} |
44 |
|
|
|
45 |
root |
1.2 |
=item $pool->req (REQUEST_TYPE, [request-args], $callback) |
46 |
|
|
|
47 |
|
|
=item $fd = $pool->fileno |
48 |
|
|
|
49 |
|
|
=item $nreqs = $pool->nreqs |
50 |
|
|
|
51 |
|
|
=item $nready = $pool->nready |
52 |
|
|
|
53 |
|
|
=item $npending = $pool->npending |
54 |
|
|
|
55 |
|
|
=item $threadcount = $pool->nthreads |
56 |
|
|
|
57 |
|
|
=item $pool->max_poll_time ($seconds) |
58 |
|
|
|
59 |
|
|
=item $pool->max_poll_reqs ($maxreqs) |
60 |
|
|
|
61 |
|
|
=item $pool->idle_timeout ($seconds) |
62 |
|
|
|
63 |
|
|
=item $pool->max_idle ($threads) |
64 |
|
|
|
65 |
|
|
=item $pool->min_parallel ($nthreads) |
66 |
|
|
|
67 |
|
|
=item $pool->max_parallel ($nthreads) |
68 |
|
|
|
69 |
root |
1.1 |
=back |
70 |
|
|
|
71 |
|
|
=head1 AUTHOR |
72 |
|
|
|
73 |
|
|
Marc Lehmann <schmorp@schmorp.de> |
74 |
|
|
http://software.schmorp.de/pkg/AnyEvent-XSThreadPool.html |
75 |
|
|
|
76 |
|
|
=cut |
77 |
|
|
|
78 |
|
|
1 |
79 |
|
|
|