1 package TAP::Parser::Scheduler::Job;
9 TAP::Parser::Scheduler::Job - A single testing job.
17 our $VERSION = '3.34';
21 use TAP::Parser::Scheduler::Job;
25 Represents a single test 'job'.
33 my $job = TAP::Parser::Scheduler::Job->new(
34 $filename, $description
37 Given the filename and description of a test as scalars, returns a new
38 L<TAP::Parser::Scheduler::Job> object.
43 my ( $class, $name, $desc, @ctx ) = @_;
47 @ctx ? ( context => \@ctx ) : (),
51 =head2 Instance Methods
55 $self->on_finish(\&method).
57 Register a closure to be called when this job is destroyed. The callback
58 will be passed the C<TAP::Parser::Scheduler::Job> object as it's only argument.
63 my ( $self, $cb ) = @_;
64 $self->{on_finish} = $cb;
71 Called when a job is complete to unlock it. If a callback has been registered
72 with C<on_finish>, it calls it. Otherwise, it does nothing.
78 if ( my $cb = $self->{on_finish} ) {
89 These are all "getters" which return the data set for these attributes during object construction.
100 sub filename { shift->{filename} }
101 sub description { shift->{description} }
102 sub context { @{ shift->{context} || [] } }
104 =head3 C<as_array_ref>
106 For backwards compatibility in callbacks.
112 return [ $self->filename, $self->description, $self->{context} ||= [] ];
119 Returns false indicating that this is a real job rather than a
120 'spinner'. Spinners are returned when the scheduler still has pending
121 jobs but can't (because of locking) return one right now.