Problem: several data members in stream_connecter_base_t are visible more than necessary

Solution: make them private and adapt initialization order
This commit is contained in:
Simon Giesecke 2019-01-31 10:11:31 -05:00
parent a766a4b67e
commit a40a3b7a34
2 changed files with 22 additions and 24 deletions

View File

@ -44,11 +44,11 @@ zmq::stream_connecter_base_t::stream_connecter_base_t (
_addr (addr_),
_s (retired_fd),
_handle (static_cast<handle_t> (NULL)),
_socket (session_->get_socket ()),
_delayed_start (delayed_start_),
_reconnect_timer_started (false),
_session (session_),
_current_reconnect_ivl (options.reconnect_ivl),
_socket (_session->get_socket ())
_current_reconnect_ivl (options.reconnect_ivl)
{
zmq_assert (_addr);
_addr->to_string (_endpoint);

View File

@ -53,21 +53,6 @@ class stream_connecter_base_t : public own_t, public io_object_t
~stream_connecter_base_t ();
private:
// ID of the timer used to delay the reconnection.
enum
{
reconnect_timer_id = 1
};
// Internal function to return a reconnect backoff delay.
// Will modify the current_reconnect_ivl used for next call
// Returns the currently used interval
int get_new_reconnect_ivl ();
virtual void start_connecting () = 0;
// TODO check if some members can be made private
protected:
// Handlers for incoming commands.
void process_plug ();
@ -100,6 +85,26 @@ class stream_connecter_base_t : public own_t, public io_object_t
// registered with the poller, or NULL.
handle_t _handle;
// String representation of endpoint to connect to
std::string _endpoint;
// Socket
zmq::socket_base_t *const _socket;
private:
// ID of the timer used to delay the reconnection.
enum
{
reconnect_timer_id = 1
};
// Internal function to return a reconnect backoff delay.
// Will modify the current_reconnect_ivl used for next call
// Returns the currently used interval
int get_new_reconnect_ivl ();
virtual void start_connecting () = 0;
// If true, connecter is waiting a while before trying to connect.
const bool _delayed_start;
@ -112,13 +117,6 @@ class stream_connecter_base_t : public own_t, public io_object_t
// Current reconnect ivl, updated for backoff strategy
int _current_reconnect_ivl;
// String representation of endpoint to connect to
std::string _endpoint;
// Socket
zmq::socket_base_t *const _socket;
private:
stream_connecter_base_t (const stream_connecter_base_t &);
const stream_connecter_base_t &operator= (const stream_connecter_base_t &);
};