The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

    AI::Evolve::Befunge::Migrator - connection to migration server

SYNOPSIS

    my $migrator = AI::Evolve::Befunge::Migrator->new(Local => $socket);
    $migrator->spin() while $migrator->alive();

DESCRIPTION

Maintains a connection to the migration server, migrationd. This module is meant to run in a child process, which will die when the Local socket is closed.

It provides a non-blocking, fault tolerant adaptation layer between migrationd (which may be somewhere across the internet) and the AI::Evolve::Befunge population object (which spends most of its time evolving critters, and only occasionally polls us).

CONSTRUCTOR

new

    my $migrator = AI::Evolve::Befunge::Migrator->new(Local => $socket);

Construct a new Migrator object.

The Local parameter is mandatory, it is the socket (typically a UNIX domain socket) used to pass critters to and from the parent process.

Note that you probably don't want to call this directly... in most cases you should call spawn_migrator, see below.

spawn_migrator

    my $socket = spawn_migrator($config);

Spawn off an external migration child process. This process will live as long as the returned socket lives; it will die when the socket is closed. See AI::Evolve::Befunge::Migrator for implementation details.

METHODS

spin

    $migrator->spin();

This is the main control component of this module. It looks for incoming events and responds to them.

spin_reads

    $migrator->spin_reads();

Handle read-related events. This method will delay for up to 2 seconds if no reading is necessary.

spin_writes

    $migrator->spin_writes();

Handle write-related events. This method will not block.

spin_exceptions

    $migrator->spin_exceptions();

Handle exception-related events. This method will not block.

alive

    exit unless $migrator->alive();

Returns true while migrator still wants to live.

try_connect

    $migrator->try_connect();

Try to establish a new connection to migrationd.