HTTP::Daemon::Threaded


HTTP-Daemon-Threaded documentation Contained in the HTTP-Daemon-Threaded distribution.

Index


Code Index:


HTTP-Daemon-Threaded documentation Contained in the HTTP-Daemon-Threaded distribution.
package HTTP::Daemon::Threaded;

use threads;
use Thread::Apartment;

use base qw(Thread::Apartment);

use strict;
use warnings;

our $VERSION = '0.91';

our $container;
our $timeout;

sub setTimeout { $timeout = ($_[0] eq 'HTTP::Daemon::Threaded') ? $_[1] : $_[0]; }

sub new {
#
#	overrides T::A new, returning the container object
#
	my ($class, %args) = @_;

	$args{AptClass} = 'HTTP::Daemon::Threaded::Listener';
	$args{AptTimeout} = $timeout
		unless exists $args{AptTimeout};

	$container = Thread::Apartment->new( %args )
		|| die "Could not install into an apartment: $@.";
	return $container;
}

1;