~ubuntu-branches/ubuntu/quantal/padre/quantal

« back to all changes in this revision

Viewing changes to t/23_task_chain.t

  • Committer: Package Import Robot
  • Author(s): Dominique Dumont, gregor herrmann, Dominique Dumont
  • Date: 2012-01-04 12:04:20 UTC
  • mfrom: (1.3.3)
  • Revision ID: package-import@ubuntu.com-20120104120420-i5oybqwf91m1d3il
Tags: 0.92.ds1-1
[ gregor herrmann ]
* Remove debian/source/local-options; abort-on-upstream-changes
  and unapply-patches are default in dpkg-source since 1.16.1.
* Swap order of alternative (build) dependencies after the perl
  5.14 transition.

[ Dominique Dumont ]
* Imported Upstream version 0.92.ds1
* removed fix-spelling patch (applied upstream)
* lintian-override: use wildcard to avoid listing a gazillion files
* updated size of some 'not-real-man-page' entries
* rules: remove dekstop cruft (replaced by a file provided in debian
  directory)
* control: removed Breaks statement. Add /me to uploaders. Updated
  dependencies
* rules: make sure that non-DFSG file (i.e. the cute butterfly, sigh)
  is not distributed

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
# BEGIN {
6
6
# $Padre::Logger::DEBUG = 1;
7
 
# $Padre::TaskThread::DEBUG = 1;
 
7
# $Padre::TaskWorker::DEBUG = 1;
8
8
# $Padre::TaskWorker::DEBUG = 1;
9
9
# }
10
10
 
22
22
}
23
23
use Time::HiRes 'sleep';
24
24
use Padre::Logger;
25
 
use Padre::TaskThread ();
 
25
use Padre::TaskWorker ();
26
26
use Padre::TaskWorker ();
27
27
 
28
28
 
42
42
SCOPE: {
43
43
 
44
44
        # Create the master thread
45
 
        my $master = Padre::TaskThread->new->spawn;
46
 
        isa_ok( $master, 'Padre::TaskThread' );
 
45
        my $master = Padre::TaskWorker->new->spawn;
 
46
        isa_ok( $master, 'Padre::TaskWorker' );
47
47
        is( scalar( threads->list ), 1, 'Found 1 thread' );
48
 
        ok( $master->is_running, 'Master is_running' );
 
48
        ok( $master->thread->is_running, 'Master is_running' );
49
49
 
50
50
        # Create a single worker
51
51
        my $worker = Padre::TaskWorker->new;
52
52
        isa_ok( $worker, 'Padre::TaskWorker' );
53
53
 
54
54
        # Start the worker inside the master
55
 
        ok( $master->start($worker), '->add ok' );
 
55
        ok( $master->send_child($worker), '->add ok' );
56
56
        TRACE("Pausing to allow worker thread startup...") if DEBUG;
57
57
        sleep 0.15; #0.1 was not enough
58
58
        is( scalar( threads->list ), 2, 'Found 2 threads' );
59
 
        ok( $master->is_running,   'Master is_running' );
60
 
        ok( !$master->is_joinable, 'Master is not is_joinable' );
61
 
        ok( !$master->is_detached, 'Master is not is_detached' );
62
 
        ok( $worker->is_running,   'Worker is_running' );
63
 
        ok( !$worker->is_joinable, 'Worker is not is_joinable' );
64
 
        ok( !$worker->is_detached, 'Worker is not is_detached' );
 
59
        ok( $master->thread->is_running,   'Master is_running' );
 
60
        ok( !$master->thread->is_joinable, 'Master is not is_joinable' );
 
61
        ok( !$master->thread->is_detached, 'Master is not is_detached' );
 
62
        ok( $worker->thread->is_running,   'Worker is_running' );
 
63
        ok( !$worker->thread->is_joinable, 'Worker is not is_joinable' );
 
64
        ok( !$worker->thread->is_detached, 'Worker is not is_detached' );
65
65
 
66
66
        # Shut down the worker but leave the master running
67
 
        ok( $worker->stop, '->stop ok' );
 
67
        ok( $worker->send_stop, '->send_stop ok' );
68
68
        TRACE("Pausing to allow worker thread shutdown...") if DEBUG;
69
69
        sleep 0.1;
70
 
        ok( $master->is_running,   'Master is_running' );
71
 
        ok( !$master->is_joinable, 'Master is not is_joinable' );
72
 
        ok( !$master->is_detached, 'Master is not is_detached' );
73
 
        ok( !$worker->thread,      'Worker thread has ended' );
 
70
        ok( $master->thread->is_running,   'Master is_running' );
 
71
        ok( !$master->thread->is_joinable, 'Master is not is_joinable' );
 
72
        ok( !$master->thread->is_detached, 'Master is not is_detached' );
 
73
 
 
74
        # Join the thread
 
75
        $worker->thread->join;
 
76
        ok( !$worker->thread, 'Worker thread has ended' );
74
77
}
75
78
 
76
79
is( scalar( threads->list ), 1, 'Thread is gone' );