Debian lenny version packages
[pkg-perl] / deb-src / libtest-harness-perl / libtest-harness-perl-3.12 / lib / TAP / Parser / Scheduler / Job.pm
1 package TAP::Parser::Scheduler::Job;
2
3 use strict;
4 use vars qw($VERSION);
5 use Carp;
6
7 =head1 NAME
8
9 TAP::Parser::Scheduler::Job - A single testing job.
10
11 =head1 VERSION
12
13 Version 3.12
14
15 =cut
16
17 $VERSION = '3.12';
18
19 =head1 SYNOPSIS
20
21     use TAP::Parser::Scheduler::Job;
22
23 =head1 DESCRIPTION
24
25 Represents a single test 'job'.
26
27 =head1 METHODS
28
29 =head2 Class Methods
30
31 =head3 C<new>
32
33     my $job = TAP::Parser::Scheduler::Job->new(
34         $name, $desc 
35     );
36
37 Returns a new C<TAP::Parser::Scheduler::Job> object.
38
39 =cut
40
41 sub new {
42     my ( $class, $name, $desc, @ctx ) = @_;
43     return bless {
44         filename    => $name,
45         description => $desc,
46         context     => \@ctx,
47     }, $class;
48 }
49
50 =head3 C<on_finish>
51
52 Register a closure to be called when this job is destroyed.
53
54 =cut
55
56 sub on_finish {
57     my ( $self, $cb ) = @_;
58     $self->{on_finish} = $cb;
59 }
60
61 =head3 C<finish>
62
63 Called when a job is complete to unlock it.
64
65 =cut
66
67 sub finish {
68     my $self = shift;
69     if ( my $cb = $self->{on_finish} ) {
70         $cb->($self);
71     }
72 }
73
74 =head3 C<filename>
75
76 =head3 C<description>
77
78 =head3 C<context>
79
80 =cut
81
82 sub filename    { shift->{filename} }
83 sub description { shift->{description} }
84 sub context     { @{ shift->{context} } }
85
86 =head3 C<as_array_ref>
87
88 For backwards compatibility in callbacks.
89
90 =cut
91
92 sub as_array_ref {
93     my $self = shift;
94     return [ $self->filename, $self->description, $self->context ];
95 }
96
97 =head3 C<is_spinner>
98
99 Returns false indicating that this is a real job rather than a
100 'spinner'. Spinners are returned when the scheduler still has pending
101 jobs but can't (because of locking) return one right now.
102
103 =cut
104
105 sub is_spinner {0}
106
107 1;