mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-15 23:20:09 +02:00
Problem: several fields are non-const without need
Solution: add const where easily possible
This commit is contained in:
@@ -56,7 +56,7 @@ struct address_t
|
|||||||
|
|
||||||
const std::string protocol;
|
const std::string protocol;
|
||||||
const std::string address;
|
const std::string address;
|
||||||
ctx_t *parent;
|
ctx_t *const parent;
|
||||||
|
|
||||||
// Protocol specific resolved address
|
// Protocol specific resolved address
|
||||||
union
|
union
|
||||||
|
@@ -122,7 +122,7 @@ class shared_message_memory_allocator
|
|||||||
private:
|
private:
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
std::size_t bufsize;
|
std::size_t bufsize;
|
||||||
std::size_t max_size;
|
const std::size_t max_size;
|
||||||
zmq::msg_t::content_t *msg_content;
|
zmq::msg_t::content_t *msg_content;
|
||||||
std::size_t maxCounters;
|
std::size_t maxCounters;
|
||||||
};
|
};
|
||||||
|
@@ -60,9 +60,9 @@ template <typename T> class encoder_base_t : public i_encoder
|
|||||||
next (NULL),
|
next (NULL),
|
||||||
new_msg_flag (false),
|
new_msg_flag (false),
|
||||||
bufsize (bufsize_),
|
bufsize (bufsize_),
|
||||||
|
buf ((unsigned char *) malloc (bufsize_)),
|
||||||
in_progress (NULL)
|
in_progress (NULL)
|
||||||
{
|
{
|
||||||
buf = (unsigned char *) malloc (bufsize_);
|
|
||||||
alloc_assert (buf);
|
alloc_assert (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,8 +166,8 @@ template <typename T> class encoder_base_t : public i_encoder
|
|||||||
bool new_msg_flag;
|
bool new_msg_flag;
|
||||||
|
|
||||||
// The buffer for encoded data.
|
// The buffer for encoded data.
|
||||||
size_t bufsize;
|
const size_t bufsize;
|
||||||
unsigned char *buf;
|
unsigned char *const buf;
|
||||||
|
|
||||||
encoder_base_t (const encoder_base_t &);
|
encoder_base_t (const encoder_base_t &);
|
||||||
void operator= (const encoder_base_t &);
|
void operator= (const encoder_base_t &);
|
||||||
|
@@ -77,7 +77,7 @@ class mailbox_safe_t : public i_mailbox
|
|||||||
condition_variable_t cond_var;
|
condition_variable_t cond_var;
|
||||||
|
|
||||||
// Synchronize access to the mailbox from receivers and senders
|
// Synchronize access to the mailbox from receivers and senders
|
||||||
mutex_t *sync;
|
mutex_t *const sync;
|
||||||
|
|
||||||
std::vector<zmq::signaler_t *> signalers;
|
std::vector<zmq::signaler_t *> signalers;
|
||||||
|
|
||||||
|
@@ -128,7 +128,7 @@ class mechanism_t
|
|||||||
// Properties received from ZAP server.
|
// Properties received from ZAP server.
|
||||||
metadata_t::dict_t zap_properties;
|
metadata_t::dict_t zap_properties;
|
||||||
|
|
||||||
options_t options;
|
const options_t options;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
blob_t routing_id;
|
blob_t routing_id;
|
||||||
|
@@ -62,7 +62,7 @@ class metadata_t
|
|||||||
atomic_counter_t ref_cnt;
|
atomic_counter_t ref_cnt;
|
||||||
|
|
||||||
// Dictionary holding metadata.
|
// Dictionary holding metadata.
|
||||||
dict_t dict;
|
const dict_t dict;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -134,7 +134,7 @@ class object_t
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// Context provides access to the global state.
|
// Context provides access to the global state.
|
||||||
zmq::ctx_t *ctx;
|
zmq::ctx_t *const ctx;
|
||||||
|
|
||||||
// Thread ID of the thread the object belongs to.
|
// Thread ID of the thread the object belongs to.
|
||||||
uint32_t tid;
|
uint32_t tid;
|
||||||
|
@@ -670,9 +670,9 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
|
|||||||
*w_ = *r_ = -1;
|
*w_ = *r_ = -1;
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
// If there's no SOCK_CLOEXEC, let's try the second best option. Note that
|
// If there's no SOCK_CLOEXEC, let's try the second best option. Note that
|
||||||
// race condition can cause socket not to be closed (if fork happens
|
// race condition can cause socket not to be closed (if fork happens
|
||||||
// between socket creation and this point).
|
// between socket creation and this point).
|
||||||
#if !defined ZMQ_HAVE_SOCK_CLOEXEC && defined FD_CLOEXEC
|
#if !defined ZMQ_HAVE_SOCK_CLOEXEC && defined FD_CLOEXEC
|
||||||
rc = fcntl (sv[0], F_SETFD, FD_CLOEXEC);
|
rc = fcntl (sv[0], F_SETFD, FD_CLOEXEC);
|
||||||
errno_assert (rc != -1);
|
errno_assert (rc != -1);
|
||||||
|
@@ -285,7 +285,7 @@ class socket_base_t : public own_t,
|
|||||||
std::string last_endpoint;
|
std::string last_endpoint;
|
||||||
|
|
||||||
// Indicate if the socket is thread safe
|
// Indicate if the socket is thread safe
|
||||||
bool thread_safe;
|
const bool thread_safe;
|
||||||
|
|
||||||
// Signaler to be used in the reaping stage
|
// Signaler to be used in the reaping stage
|
||||||
signaler_t *reaper_signaler;
|
signaler_t *reaper_signaler;
|
||||||
|
@@ -178,7 +178,7 @@ class stream_engine_t : public io_object_t, public i_engine
|
|||||||
// The session this engine is attached to.
|
// The session this engine is attached to.
|
||||||
zmq::session_base_t *session;
|
zmq::session_base_t *session;
|
||||||
|
|
||||||
options_t options;
|
const options_t options;
|
||||||
|
|
||||||
// String representation of endpoint
|
// String representation of endpoint
|
||||||
std::string endpoint;
|
std::string endpoint;
|
||||||
|
@@ -72,12 +72,15 @@ zmq::tcp_connecter_t::tcp_connecter_t (class io_thread_t *io_thread_,
|
|||||||
connect_timer_started (false),
|
connect_timer_started (false),
|
||||||
reconnect_timer_started (false),
|
reconnect_timer_started (false),
|
||||||
session (session_),
|
session (session_),
|
||||||
current_reconnect_ivl (options.reconnect_ivl)
|
current_reconnect_ivl (options.reconnect_ivl),
|
||||||
|
socket (session->get_socket ())
|
||||||
{
|
{
|
||||||
zmq_assert (addr);
|
zmq_assert (addr);
|
||||||
zmq_assert (addr->protocol == "tcp");
|
zmq_assert (addr->protocol == "tcp");
|
||||||
addr->to_string (endpoint);
|
addr->to_string (endpoint);
|
||||||
socket = session->get_socket ();
|
// TODO the return value is unused! what if it fails? if this is impossible
|
||||||
|
// or does not matter, change such that endpoint in initialized using an
|
||||||
|
// initializer, and make endpoint const
|
||||||
}
|
}
|
||||||
|
|
||||||
zmq::tcp_connecter_t::~tcp_connecter_t ()
|
zmq::tcp_connecter_t::~tcp_connecter_t ()
|
||||||
|
@@ -97,7 +97,7 @@ class tcp_connecter_t : public own_t, public io_object_t
|
|||||||
fd_t connect ();
|
fd_t connect ();
|
||||||
|
|
||||||
// Address to connect to. Owned by session_base_t.
|
// Address to connect to. Owned by session_base_t.
|
||||||
address_t *addr;
|
address_t *const addr;
|
||||||
|
|
||||||
// Underlying socket.
|
// Underlying socket.
|
||||||
fd_t s;
|
fd_t s;
|
||||||
@@ -117,7 +117,7 @@ class tcp_connecter_t : public own_t, public io_object_t
|
|||||||
bool reconnect_timer_started;
|
bool reconnect_timer_started;
|
||||||
|
|
||||||
// Reference to the session we belong to.
|
// Reference to the session we belong to.
|
||||||
zmq::session_base_t *session;
|
zmq::session_base_t *const session;
|
||||||
|
|
||||||
// Current reconnect ivl, updated for backoff strategy
|
// Current reconnect ivl, updated for backoff strategy
|
||||||
int current_reconnect_ivl;
|
int current_reconnect_ivl;
|
||||||
@@ -126,7 +126,7 @@ class tcp_connecter_t : public own_t, public io_object_t
|
|||||||
std::string endpoint;
|
std::string endpoint;
|
||||||
|
|
||||||
// Socket
|
// Socket
|
||||||
zmq::socket_base_t *socket;
|
zmq::socket_base_t *const socket;
|
||||||
|
|
||||||
tcp_connecter_t (const tcp_connecter_t &);
|
tcp_connecter_t (const tcp_connecter_t &);
|
||||||
const tcp_connecter_t &operator= (const tcp_connecter_t &);
|
const tcp_connecter_t &operator= (const tcp_connecter_t &);
|
||||||
|
@@ -54,7 +54,7 @@ class v1_decoder_t : public zmq::c_single_allocator,
|
|||||||
unsigned char tmpbuf[8];
|
unsigned char tmpbuf[8];
|
||||||
msg_t in_progress;
|
msg_t in_progress;
|
||||||
|
|
||||||
int64_t maxmsgsize;
|
const int64_t maxmsgsize;
|
||||||
|
|
||||||
v1_decoder_t (const v1_decoder_t &);
|
v1_decoder_t (const v1_decoder_t &);
|
||||||
void operator= (const v1_decoder_t &);
|
void operator= (const v1_decoder_t &);
|
||||||
|
Reference in New Issue
Block a user