Problem: inconsistent naming style for private data members, conflicts with naming of local variables and member functions

Solution: apply and check _lower_case naming style for private data members
This commit is contained in:
Simon Giesecke
2018-05-27 11:10:39 +02:00
parent 06cfd0d8ad
commit e3c73d9881
143 changed files with 5783 additions and 4051 deletions

View File

@@ -32,12 +32,12 @@
#include "clock.hpp"
#include "err.hpp"
zmq::mailbox_safe_t::mailbox_safe_t (mutex_t *sync_) : sync (sync_)
zmq::mailbox_safe_t::mailbox_safe_t (mutex_t *sync_) : _sync (sync_)
{
// Get the pipe into passive state. That way, if the users starts by
// polling on the associated file descriptor it will get woken up when
// new command is posted.
const bool ok = cpipe.check_read ();
const bool ok = _cpipe.check_read ();
zmq_assert (!ok);
}
@@ -47,66 +47,66 @@ zmq::mailbox_safe_t::~mailbox_safe_t ()
// Work around problem that other threads might still be in our
// send() method, by waiting on the mutex before disappearing.
sync->lock ();
sync->unlock ();
_sync->lock ();
_sync->unlock ();
}
void zmq::mailbox_safe_t::add_signaler (signaler_t *signaler_)
{
signalers.push_back (signaler_);
_signalers.push_back (signaler_);
}
void zmq::mailbox_safe_t::remove_signaler (signaler_t *signaler_)
{
std::vector<signaler_t *>::iterator it = signalers.begin ();
std::vector<signaler_t *>::iterator it = _signalers.begin ();
// TODO: make a copy of array and signal outside the lock
for (; it != signalers.end (); ++it) {
for (; it != _signalers.end (); ++it) {
if (*it == signaler_)
break;
}
if (it != signalers.end ())
signalers.erase (it);
if (it != _signalers.end ())
_signalers.erase (it);
}
void zmq::mailbox_safe_t::clear_signalers ()
{
signalers.clear ();
_signalers.clear ();
}
void zmq::mailbox_safe_t::send (const command_t &cmd_)
{
sync->lock ();
cpipe.write (cmd_, false);
const bool ok = cpipe.flush ();
_sync->lock ();
_cpipe.write (cmd_, false);
const bool ok = _cpipe.flush ();
if (!ok) {
cond_var.broadcast ();
for (std::vector<signaler_t *>::iterator it = signalers.begin ();
it != signalers.end (); ++it) {
_cond_var.broadcast ();
for (std::vector<signaler_t *>::iterator it = _signalers.begin ();
it != _signalers.end (); ++it) {
(*it)->send ();
}
}
sync->unlock ();
_sync->unlock ();
}
int zmq::mailbox_safe_t::recv (command_t *cmd_, int timeout_)
{
// Try to get the command straight away.
if (cpipe.read (cmd_))
if (_cpipe.read (cmd_))
return 0;
// Wait for signal from the command sender.
int rc = cond_var.wait (sync, timeout_);
int rc = _cond_var.wait (_sync, timeout_);
if (rc == -1) {
errno_assert (errno == EAGAIN || errno == EINTR);
return -1;
}
// Another thread may already fetch the command
const bool ok = cpipe.read (cmd_);
const bool ok = _cpipe.read (cmd_);
if (!ok) {
errno = EAGAIN;