1TAP::Parser::MultiplexeUrs(e3r)Contributed Perl DocumentTaAtPi:o:nParser::Multiplexer(3)
2
3
4
6 TAP::Parser::Multiplexer - Multiplex multiple TAP::Parsers
7
9 Version 3.28
10
12 use TAP::Parser::Multiplexer;
13
14 my $mux = TAP::Parser::Multiplexer->new;
15 $mux->add( $parser1, $stash1 );
16 $mux->add( $parser2, $stash2 );
17 while ( my ( $parser, $stash, $result ) = $mux->next ) {
18 # do stuff
19 }
20
22 "TAP::Parser::Multiplexer" gathers input from multiple TAP::Parsers.
23 Internally it calls select on the input file handles for those parsers
24 to wait for one or more of them to have input available.
25
26 See TAP::Harness for an example of its use.
27
29 Class Methods
30 "new"
31
32 my $mux = TAP::Parser::Multiplexer->new;
33
34 Returns a new "TAP::Parser::Multiplexer" object.
35
36 Instance Methods
37 "add"
38
39 $mux->add( $parser, $stash );
40
41 Add a TAP::Parser to the multiplexer. $stash is an optional opaque
42 reference that will be returned from "next" along with the parser and
43 the next result.
44
45 "parsers"
46
47 my $count = $mux->parsers;
48
49 Returns the number of parsers. Parsers are removed from the multiplexer
50 when their input is exhausted.
51
52 "next"
53
54 Return a result from the next available parser. Returns a list
55 containing the parser from which the result came, the stash that
56 corresponds with that parser and the result.
57
58 my ( $parser, $stash, $result ) = $mux->next;
59
60 If $result is undefined the corresponding parser has reached the end of
61 its input (and will automatically be removed from the multiplexer).
62
63 When all parsers are exhausted an empty list will be returned.
64
65 if ( my ( $parser, $stash, $result ) = $mux->next ) {
66 if ( ! defined $result ) {
67 # End of this parser
68 }
69 else {
70 # Process result
71 }
72 }
73 else {
74 # All parsers finished
75 }
76
78 TAP::Parser
79
80 TAP::Harness
81
82
83
84perl v5.16.3 2013-05-02 TAP::Parser::Multiplexer(3)