File Coverage

blib/lib/ZMQ/Raw/Poller.pm
Criterion Covered Total %
statement 9 10 90.0
branch n/a
condition n/a
subroutine 3 4 75.0
pod n/a
total 12 14 85.7


line stmt bran cond sub pod time code
1             package ZMQ::Raw::Poller;
2             $ZMQ::Raw::Poller::VERSION = '0.37';
3 14     14   78 use strict;
  14         22  
  14         325  
4 14     14   51 use warnings;
  14         25  
  14         261  
5 14     14   54 use ZMQ::Raw;
  14         17  
  14         582  
6              
7 0     0     sub CLONE_SKIP { 1 }
8              
9             =head1 NAME
10              
11             ZMQ::Raw::Poller - ZeroMQ Poller class
12              
13             =head1 VERSION
14              
15             version 0.37
16              
17             =head1 DESCRIPTION
18              
19             ZeroMQ Poller
20              
21             =head1 SYNOPSIS
22              
23             use ZMQ::Raw;
24              
25             my $poller = ZMQ::Raw::Poller->new();
26             $poller->add ($socket1, ZMQ::Raw->ZMQ_POLLIN);
27             $poller->add ($socket2, ZMQ::Raw->ZMQ_POLLIN);
28              
29             # wait for up to 1000ms for an event
30             if ($poller->wait (1000))
31             {
32             my $events = $poller->events ($socket1);
33             if ($events & ZMQ::Raw->ZMQ_POLLIN)
34             {
35             print "POLLIN event on socket1\n";
36             }
37              
38             $events = $poller->events ($socket2);
39             if ($events & ZMQ::Raw->ZMQ_POLLIN)
40             {
41             print "POLLIN event on socket2\n";
42             }
43             }
44              
45             =head1 METHODS
46              
47             =head2 new( )
48              
49             Create a new poller.
50              
51             =head2 add( $socket, $events )
52              
53             Poll for C<$events> on C<$socket>. C<$events> is a bitmask of values including:
54              
55             =over 4
56              
57             =item * CZMQ_POLLIN>
58              
59             At least one message may be received from the socket without blocking.
60              
61             =item * CZMQ_POLLOUT>
62              
63             At least one message may be sent to the socket without blocking.
64              
65             =back
66              
67             =head2 remove( $socket )
68              
69             Remove C<$socket> from the list of sockets to poll for events.
70              
71             =head2 events( $socket )
72              
73             Retrieve the events for C<$socket>. If C<$socket> was not previously added to
74             the poller this method will return C.
75              
76             =head2 wait ( $timeout )
77              
78             Wait for up to C<$timeout> milliseconds for an event. Returns the number of
79             items that had events.
80              
81             This method may return C if the system call was interrupt, after which
82             it may be reattempted.
83              
84             =head2 size( )
85              
86             Retrieve the number of sockets currently polled.
87              
88             =head1 AUTHOR
89              
90             Jacques Germishuys
91              
92             =head1 LICENSE AND COPYRIGHT
93              
94             Copyright 2017 Jacques Germishuys.
95              
96             This program is free software; you can redistribute it and/or modify it
97             under the terms of either: the GNU General Public License as published
98             by the Free Software Foundation; or the Artistic License.
99              
100             See http://dev.perl.org/licenses/ for more information.
101              
102             =cut
103              
104             1; # End of ZMQ::Raw::Poller