0.005_01 commit
[poe-xs-queue-array.git] / Array.pm
CommitLineData
e38f8ec4
TC
1package POE::XS::Queue::Array;
2use strict;
3use vars qw(@ISA $VERSION);
4use POE::Queue;
5
e38f8ec4 6BEGIN {
a603f2ce 7 @ISA = qw(POE::Queue);
412143dd 8 $VERSION = '0.005_01';
e38f8ec4
TC
9 eval {
10 # try XSLoader first, DynaLoader has annoying baggage
11 require XSLoader;
12 XSLoader::load('POE::XS::Queue::Array' => $VERSION);
13 1;
14 } or do {
15 require DynaLoader;
16 push @ISA, 'DynaLoader';
17 bootstrap POE::XS::Queue::Array $VERSION;
18 }
19}
20
21# lifted from POE::Queue::Array
22sub ITEM_PRIORITY () { 0 }
23sub ITEM_ID () { 1 }
24sub ITEM_PAYLOAD () { 2 }
25
26sub import {
27 my $package = caller();
28 no strict 'refs';
29 *{ $package . '::ITEM_PRIORITY' } = \&ITEM_PRIORITY;
30 *{ $package . '::ITEM_ID' } = \&ITEM_ID;
31 *{ $package . '::ITEM_PAYLOAD' } = \&ITEM_PAYLOAD;
32}
33
34# everything else is XS
351;
36
37__END__
38
39=head1 NAME
40
41POE::XS::Queue::Array - an XS implementation of POE::Queue::Array.
42
43=head1 SYNOPSIS
44
45See POE::Queue.
46
47=head1 DESCRIPTION
48
49This class is an implementation of the abstract POE::Queue interface.
50It implements a priority queue using C, with an XS interface supplied.
51
52The current implementation could use some optimization, especially for
53large queues.
54
1351c36f 55Please see the POE::Queue documentation, which explains this one's
e38f8ec4
TC
56functions, features, and behavior.
57
1351c36f
TC
58The following extra methods are added beyond POE::Queue::Array:
59
60=over
61
62=item dump
63
64Dumps the internal structure of the queue to stderr.
65
66=item verify
67
68Does limited verification of the structure of the queue. If the
69verification fails then a message is sent to stderr and the queue is
70dumped as with the dump() method, and your program will exit.
71
72=back
73
e38f8ec4
TC
74=head1 SEE ALSO
75
76POE, POE::Queue, POE::Queue::Array
77
78=head1 BUGS
79
80None known.
81
82Some possible improvements include:
83
84=over
85
86=item *
87
e38f8ec4
TC
88use a B-Tree for the queue (not a binary tree, a B-Tree), though this
89would require a module rename.
90
91=item *
92
93use a custom hash instead of a HV for the id to priority mapping,
94either glib's hash or convert to C++ and use the STL map.
95
96=item *
97
98some of the XS code could be optimized to do less work in scalar
99context, pq_remove_items and pq_peek_items could avoid building all
100those array refs.
101
102=back
103
fce9821a
TC
104=head1 LICENSE
105
106POE::XS::Queue::Array is licensed under the same terms as Perl itself.
107
e38f8ec4
TC
108=head1 AUTHOR
109
110Tony Cook <tonyc@cpan.org>
111
112=cut
113
114