[Slim-Checkins] r8805 - /trunk/server/Slim/Utils/Timers.pm
andy at svn.slimdevices.com
andy at svn.slimdevices.com
Fri Aug 4 21:49:25 PDT 2006
Author: andy
Date: Fri Aug 4 21:49:23 2006
New Revision: 8805
URL: http://svn.slimdevices.com?rev=8805&view=rev
Log:
Add support for POE::XS::Queue::Array 0.002
Modified:
trunk/server/Slim/Utils/Timers.pm
Modified: trunk/server/Slim/Utils/Timers.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Utils/Timers.pm?rev=8805&r1=8804&r2=8805&view=diff
==============================================================================
--- trunk/server/Slim/Utils/Timers.pm (original)
+++ trunk/server/Slim/Utils/Timers.pm Fri Aug 4 21:49:23 2006
@@ -36,15 +36,42 @@
#
# Timers are checked whenever we come out of select.
-# POE::XS::Queue::Array is a lot faster, but is still new and has some bugs
-my $HAS_XS = 0;
-use POE::Queue::Array;
-
-our $normal = ( $HAS_XS )
+# Use POE::XS::Queue::Array >= 0.002 if available
+BEGIN {
+ my $hasXS;
+
+ sub hasXS {
+ return $hasXS if defined $hasXS;
+
+ $hasXS = 0;
+ eval {
+ require POE::XS::Queue::Array;
+ die if $POE::XS::Queue::Array::VERSION eq '0.001'; # 0.001 has memory leaks
+ $hasXS = 1;
+ };
+ if ($@) {
+ require POE::Queue::Array;
+ }
+
+ return $hasXS;
+ }
+
+ # alias PQA's ITEM methods
+ if ( hasXS() ) {
+ *ITEM_ID = \&POE::XS::Queue::Array::ITEM_ID;
+ *ITEM_PAYLOAD = \&POE::XS::Queue::Array::ITEM_PAYLOAD;
+ }
+ else {
+ *ITEM_ID = \&POE::Queue::Array::ITEM_ID;
+ *ITEM_PAYLOAD = \&POE::Queue::Array::ITEM_PAYLOAD;
+ }
+}
+
+our $normal = ( hasXS() )
? POE::XS::Queue::Array->new()
: POE::Queue::Array->new();
-our $high = ( $HAS_XS )
+our $high = ( hasXS() )
? POE::XS::Queue::Array->new()
: POE::Queue::Array->new();
More information about the checkins
mailing list