<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package TAP::Parser::Scheduler::Job;

use strict;
use warnings;
use Carp;

=head1 NAME

TAP::Parser::Scheduler::Job - A single testing job.

=head1 VERSION

Version 3.42

=cut

our $VERSION = '3.42';

=head1 SYNOPSIS

    use TAP::Parser::Scheduler::Job;

=head1 DESCRIPTION

Represents a single test 'job'.

=head1 METHODS

=head2 Class Methods

=head3 C&lt;new&gt;

    my $job = TAP::Parser::Scheduler::Job-&gt;new(
        $filename, $description
    );

Given the filename and description of a test as scalars, returns a new
L&lt;TAP::Parser::Scheduler::Job&gt; object.

=cut

sub new {
    my ( $class, $name, $desc, @ctx ) = @_;
    return bless {
        filename    =&gt; $name,
        description =&gt; $desc,
        @ctx ? ( context =&gt; \@ctx ) : (),
    }, $class;
}

=head2 Instance Methods

=head3 C&lt;on_finish&gt;

    $self-&gt;on_finish(\&amp;method).

Register a closure to be called when this job is destroyed. The callback
will be passed the C&lt;TAP::Parser::Scheduler::Job&gt; object as it's only argument.

=cut

sub on_finish {
    my ( $self, $cb ) = @_;
    $self-&gt;{on_finish} = $cb;
}

=head3 C&lt;finish&gt;

   $self-&gt;finish;

Called when a job is complete to unlock it. If a callback has been registered
with C&lt;on_finish&gt;, it calls it. Otherwise, it does nothing. 

=cut

sub finish {
    my $self = shift;
    if ( my $cb = $self-&gt;{on_finish} ) {
        $cb-&gt;($self);
    }
}

=head2 Attributes

  $self-&gt;filename;
  $self-&gt;description;
  $self-&gt;context;

These are all "getters" which return the data set for these attributes during object construction.


=head3 C&lt;filename&gt;

=head3 C&lt;description&gt;

=head3 C&lt;context&gt;

=cut

sub filename    { shift-&gt;{filename} }
sub description { shift-&gt;{description} }
sub context     { @{ shift-&gt;{context} || [] } }

=head3 C&lt;as_array_ref&gt;

For backwards compatibility in callbacks.

=cut

sub as_array_ref {
    my $self = shift;
    return [ $self-&gt;filename, $self-&gt;description, $self-&gt;{context} ||= [] ];
}

=head3 C&lt;is_spinner&gt;

  $self-&gt;is_spinner;

Returns false indicating that this is a real job rather than a
'spinner'. Spinners are returned when the scheduler still has pending
jobs but can't (because of locking) return one right now.

=cut

sub is_spinner {0}

1;
</pre></body></html>