NAME

IPC::Manager::Service::State - Internal implementation of ipcm_service and ipcm_worker

DESCRIPTION

This module is the implementation backing the ipcm_service and ipcm_worker exports provided by IPC::Manager. It also acts as its own -M boot module when a service is started via exec: in that case Perl loads this module with -MIPC::Manager::Service::State, which reads the serialised service parameters from @ARGV and arranges for the service to start running once the Perl runtime exits BEGIN.

Callers should interact with this module only through the exports of IPC::Manager; direct use is not part of the public API.

EXPORTS

These functions are re-exported through IPC::Manager; see that module for the primary documentation.

$handle = ipcm_service($name, \&on_all_callback)
$handle = ipcm_service($name, \%params, \&on_all_callback)
$handle = ipcm_service($name, %params)

Fork a new service process. The return value depends on calling context and where the call is made:

  • When called outside a service, returns an IPC::Manager::Service::Handle connected to a newly spawned IPC bus. ipcm_service blocks until the service signals that it is ready.

  • When called from inside a running service (from a service callback), the new service shares the existing IPC bus. Returns an IPC::Manager::Service::Peer that the calling service can use to send requests to the nested service. ipcm_service blocks until the nested service is ready.

  • When called in void context from inside a service, the nested service is started but ipcm_service returns immediately without waiting for the service to be ready. The caller is responsible for waiting before sending messages; see "ipcm_service" in IPC::Manager for details.

$pid = ipcm_worker($name, \&callback)

Fork a worker process from inside a running service. The worker runs \&callback in place of a normal service loop and is registered with the parent service so that it is reaped when the service exits. Dies if called outside a service.

Returns the PID of the newly forked worker to the parent; in the worker process the callback is invoked and the function never returns.

SOURCE

The source code repository for IPC::Manager can be found at https://github.com/exodist/IPC-Manager.

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>

COPYRIGHT

Copyright Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See https://dev.perl.org/licenses/