line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Coro::Channel::Factory - Factory for named Coro::Channel queues. |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Coro::Channel::Factory; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Initialise factory |
10
|
|
|
|
|
|
|
my $factory = Coro::Channel::Factory->new(); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Get a handle to a (possibly previously undeclared) Coro::Channel, and put something.. |
13
|
|
|
|
|
|
|
my $channel = $factory->name('some channel name'); |
14
|
|
|
|
|
|
|
$channel->put($var); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Interacting directly - no intermediate handle object.. |
17
|
|
|
|
|
|
|
$factory->name('some channel name')->put($other_var); |
18
|
|
|
|
|
|
|
my $item = $factory->name('some channel name')->get; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This module provides a very simple name-binding for Coro::Channel, removing the need to track individual Coro::Channel objects. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
As long as the Coro::Channel::Factory object is available, any named Coro::Channel can be utilised. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
package Coro::Channel::Factory; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
1
|
|
20799
|
use 5.008002; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
54
|
|
31
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
32
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
52
|
|
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
|
304
|
use Coro; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
our $VERSION = '1.01'; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 API |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=over 4 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item $factory = Coro::Channel::Factory->new() |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Creates the Factory object |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=back |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub new { |
51
|
|
|
|
|
|
|
my $class = shift; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $self = {}; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
bless($self, $class); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$self->initialise(@_); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
return $self; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub initialise { |
63
|
|
|
|
|
|
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$self->{channels} = { }; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=over 4 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item $channel = $factory->name($name) |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Get or create a channel with name $name |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=back |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub name { |
79
|
|
|
|
|
|
|
my $self = shift; |
80
|
|
|
|
|
|
|
my $channelName = shift; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
if (!defined($self->{channels}->{$channelName})) { |
83
|
|
|
|
|
|
|
$self->{channels}->{$channelName} = new Coro::Channel; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
return $self->{channels}->{$channelName}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 SEE ALSO |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
L |
92
|
|
|
|
|
|
|
L |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 AUTHOR |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Phillip O'Donnell, Epodonnell@cpan.orgE |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Copyright (C) 2013 by Phillip O'Donnell |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
103
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.2 or, |
104
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
109
|
|
|
|
|
|
|
|