ControlFreak

 view release on metacpan or  search on metacpan

inc/Test/Deep/Cache/Simple.pm  view on Meta::CPAN

use strict;
use warnings;

package Test::Deep::Cache::Simple;
use Carp qw( confess );

use Scalar::Util qw( refaddr );

BEGIN
{
  if (grep /^weaken$/, @Scalar::Util::EXPORT_FAIL)
  {
    # we're running on a version of perl that has no weak refs, so we
    # just install a no-op sub for weaken instead of importing it
    *weaken = sub {};
  }
  else
  {
    Scalar::Util->import('weaken');
  }
}

sub new
{
	my $pkg = shift;

	my $self = bless {}, $pkg;

	return $self;
}

sub add
{
	my $self = shift;

	my ($d1, $d2) = @_;
	{
		local $SIG{__DIE__};

		# cannot weaken read only refs, no harm if we can't as they never
		# disappear
		eval{weaken($d1)};
		eval{weaken($d2)};
	}

	$self->{fn_get_key(@_)} = [$d1, $d2];
}

sub cmp
{
	my $self = shift;

	my $key = fn_get_key(@_);
	my $pair = $self->{$key};

	# are both weakened refs still valid, if not delete this entry
	if (ref($pair->[0]) and ref($pair->[1]))
	{
		return 1;
	}
	else
	{
		delete $self->{$key};
		return 0;
	}
}

lib/ControlFreak/Console.pm  view on Meta::CPAN

    service
    full
    started
};

sub new {
    my $console = shift->SUPER::new(@_);
    my %param = @_;
    $console->{ctrl} = $param{ctrl}
        or croak "Console requires a controller";
    Scalar::Util::weaken($console->{ctrl});
    $console->{started} = 0;
    $param{ctrl}->set_console($console);
    $console->{full} = 1;
    return $console;
}

=head1 NAME

ControlFreak::Console - Handles all communications with ControlFreak

lib/ControlFreak/Proxy.pm  view on Meta::CPAN

    $proxy->{ctrl} = $ctrl;
    $proxy->{servicemap} = {};
    $proxy->{env}  ||= {};
    unless (defined $param{auto}) {
        $proxy->{auto} = 1; # proxy is 'auto' by default
    }
    unless ($ctrl->add_proxy($proxy)) {
        $ctrl->log->error("A proxy by that name already exists");
        return;
    }
    Scalar::Util::weaken($proxy->{ctrl});
    return $proxy;
}

=head2 status_as_text

Returns the status of the proxy, including its eventual pid in one line of
text, where the following fields are seperated with tabs:

=over 4

lib/ControlFreak/Socket.pm  view on Meta::CPAN

        $ctrl->log->error("Socket creation attempt without a name");
        return;
    }

    my $socket = $class->SUPER::new(%param);
    $socket->{ctrl} = $ctrl;
    unless ($ctrl->add_socket($socket)) {
        $ctrl->log->error("A socket by that name already exists");
        return;
    }
    Scalar::Util::weaken($socket->{ctrl});
    return $socket;
}

=head2 bind

Creates, binds the socket and puts it in listen mode, then returns
immediately.
Once bound, $socket->fh will return the filehandle.

=cut



( run in 0.679 second using v1.01-cache-2.11-cpan-65fba6d93b7 )