salsa  0.4.15
PollerZmq.cc
1 #include "PollerZmq.hh"
2 #include "ActorZmq.hh"
3 
4 namespace Salsa {
5 PollerZmq::PollerZmq() : Poller(), mpPoller(zpoller_new(nullptr))
6 {
10 }
11 
13 {
17 
18  SPD_TRACE("### Destroy PollerZmq ###");
19  zpoller_destroy(&mpPoller);
20  mpPoller = nullptr;
21 }
22 
23 void PollerZmq::add(zsock_t * pSocket)
24 {
29 
30  zpoller_add(mpPoller, pSocket);
31  SPD_TRACE("Adding socket (zsock_t*) {} to poller {}", static_cast<void *>(pSocket), static_cast<void *>(this));
32 }
33 
34 void PollerZmq::add(zactor_t * pSocket)
35 {
40 
41  zpoller_add(mpPoller, pSocket);
42  SPD_TRACE("Adding socket (zactor_t*) {} to poller {}", static_cast<void *>(pSocket), static_cast<void *>(this));
43 }
44 
45 void PollerZmq::add(SocketZyre * pSocket)
46 {
51 
52  zpoller_add(mpPoller, pSocket->socket());
53  SPD_TRACE("Adding socket (Salsa::Socket*){} to poller {}", static_cast<void *>(pSocket), static_cast<void *>(this));
54 }
55 
56 void * PollerZmq::wait(int timeout)
57 {
62  // What the hell Clang?
63  // PollerZmq.cxx|53 col 8 warning| '@param' command used in a comment that is not attached to a
64  // function declaration [-Wdocumentation]
65  //
66  // Alright. I'm gonna stop you right there. For your information: I just added these comments
67  // and the warning just kinda disappeared. What. The. ...
68 
69  void * pSocket = zpoller_wait(mpPoller, timeout);
70  SPD_TRACE("wait(timeout [{}]) => socket [{}]", timeout, static_cast<void *>(pSocket));
71  return pSocket;
72 }
73 
74 } // namespace Salsa
virtual ~PollerZmq()
Definition: PollerZmq.cc:12
virtual void add(SocketZyre *pSocket)
Definition: PollerZmq.cc:45
zpoller_t * mpPoller
ZeroMQ poller.
Definition: PollerZmq.hh:30
virtual void * wait(int timeout=-1)
Waiting for socket.
Definition: PollerZmq.cc:56
Base Poller class.
Definition: Poller.hh:14
Salsa zyre socket class.
Definition: SocketZyre.hh:18
virtual zsock_t * socket() const
Returns zyre socket pointer.
Definition: SocketZyre.hh:45