ZMQ/Context.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 31 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
_wrap
2.0
term
2.0
CRAP 2.0
1 package ZMQ::Context;
2 use strict;
3 use ZMQ::Socket;
4  
5 sub new {
6 my $class = shift;
7 $class->_wrap( ZMQ::call("zmq_init", @_) );
8 }
9  
10 sub _wrap {
11 my ($class, $cxt) = @_;
12 bless { _cxt => $cxt, _sockets => [] }, $class;
13 }
14  
15 sub term {
16 my $self = shift;
17 foreach my $socket (@{ $self->{_sockets} }) {
18 $socket->close();
19 }
20  
21 ZMQ::call( "zmq_term", $self->{_cxt} );
22 }
23  
24 sub socket {
25 my $self = shift;
26 my $sock = ZMQ::Socket->_wrap(
27 ZMQ::call( "zmq_socket", $self->{_cxt}, @_ )
28 );
29 push @{$self->{_sockets}}, $sock;
30 return $sock;
31 }
32
33  
34 1;
35  
36 __END__