NAME
Linux::Event::Fork::Request - A queued spawn request when max_children is reached
SYNOPSIS
my $forker = Linux::Event::Fork->new($loop, max_children => 2);
my $h = $forker->spawn(cmd => [ ... ]);
if ($h->isa('Linux::Event::Fork::Request')) {
$h->cancel; # prevent it from ever starting
}
DESCRIPTION
When bounded parallelism is enabled (max_children) and the limit has been reached, Linux::Event::Fork enqueues the spawn request and returns a Request object.
Requests are started FIFO as capacity frees.
A Request is a handle for queued work. Once it starts, it produces a Linux::Event::Fork::Child.
EXECUTION MODEL
All methods on this object are called from the parent process.
Starting of queued requests happens in the parent, driven by the event loop when capacity becomes available.
IMPORTANT BEHAVIOR
Spec is copied at enqueue time
The original spawn spec is copied when the Request is created. Later mutation by the caller cannot affect queued work.
METHODS
cancel
my $ok = $req->cancel;
Cancels a queued request (only if it has not yet started).
Returns true on the first successful cancel, false if it was already canceled.
If the request has already started, cancel has no effect on the child.
started
if ($req->started) { ... }
True once the request has started and a child has been spawned.
child
my $child = $req->child;
Returns the Linux::Event::Fork::Child handle once the request starts.
Returns undef while still queued (or if canceled before start).
tag
my $tag = $req->tag;
Returns the tag copied from the original spawn request.
data
my $data = $req->data;
Returns the data payload copied from the original spawn request.
RELATIONSHIP TO cancel_queued
Linux::Event::Fork provides cancel_queued(...) on the forker object to cancel queued requests in bulk (typically by predicate, tag, or data).
This object-level cancel() cancels exactly one specific request handle.
AUTHOR
Joshua S. Day (HAX)
LICENSE
Same terms as Perl itself.