summaryrefslogtreecommitdiff
path: root/t/signal.t
blob: 81e984e2a3252315bf86dc532f54bb7ae8ebcadd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!perl 
use strict;
use warnings;
use Test::Most tests => 10, 'die';
use threads;
use lib 't/lib';
use Thread::Task::Manager;
use Test::Addition;
use Test::Conduit;
 
is( scalar( threads->list ), 0, 'No threads' );
SCOPE: {
        my $conduit = Test::Conduit->new();
 
        my $manager = Thread::Task::Manager->new( conduit => $conduit );
        isa_ok( $manager'Thread::Task::Manager' );
        is( scalar( threads->list ), 0, 'No threads' );
 
        # Run the startup process 
        $manager->start;
        sleep(1);
        is( scalar( threads->list ), $manager->minimum+1, 'Three threads exists' );
 
        # Create the sample task 
        my $addition = Test::Addition->new(
                => 2,
                => 3,
        );
        isa_ok( $addition'Test::Addition' );
 
        # Schedule the task (which should trigger its execution) 
        $manager->schedule($addition);
 
        # Only the prepare phase should run (for now) 
        is( $addition->prepare_cnt, 1, '->prepare_cnt is 1' );
        is( $addition->run_cnt,     0, '->run_cnt     is 0' );
        is( $addition->finish_cnt,  0, '->finish_cnt  is 0' );
 
        $conduit->runonce();
        $conduit->runonce();
 
        # Run the shutdown process 
        $manager->stop;
        sleep(1);
        is( scalar( threads->list ), 0, 'No threads' );
}
 
# Do we start with no threads as expected 
is( scalar( threads->list ), 0, 'No threads' );