Problem: inconsistent polymorphic inheritance

Solution: consistently use virtual, override and final
This commit is contained in:
Simon Giesecke 2019-12-24 10:39:26 +01:00
parent 6d69898240
commit 628adf1cb7
84 changed files with 525 additions and 487 deletions

View File

@ -420,3 +420,7 @@ CheckOptions:
# value: '0'
# - key: readability-simplify-boolean-expr.ChainedConditionalReturn
# value: '0'
- key: modernize-use-override.OverrideSpelling
value: 'ZMQ_OVERRIDE'
- key: modernize-use-override.FinalSpelling
value: 'ZMQ_FINAL'

View File

@ -41,24 +41,24 @@ class msg_t;
class pipe_t;
class io_thread_t;
class client_t : public socket_base_t
class client_t ZMQ_FINAL : public socket_base_t
{
public:
client_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~client_t ();
~client_t () ZMQ_FINAL;
protected:
// Overrides of functions from socket_base_t.
void xattach_pipe (zmq::pipe_t *pipe_,
bool subscribe_to_all_,
bool locally_initiated_);
int xsend (zmq::msg_t *msg_);
int xrecv (zmq::msg_t *msg_);
bool xhas_in ();
bool xhas_out ();
void xread_activated (zmq::pipe_t *pipe_);
void xwrite_activated (zmq::pipe_t *pipe_);
void xpipe_terminated (zmq::pipe_t *pipe_);
bool locally_initiated_) ZMQ_FINAL;
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_in () ZMQ_FINAL;
bool xhas_out () ZMQ_FINAL;
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
private:
// Messages are fair-queued from inbound pipes. And load-balanced to

View File

@ -90,7 +90,7 @@ class thread_ctx_t
// Context object encapsulates all the global state associated with
// the library.
class ctx_t : public thread_ctx_t
class ctx_t ZMQ_FINAL : public thread_ctx_t
{
public:
// Create the context object.

View File

@ -41,18 +41,18 @@ namespace zmq
class msg_t;
class session_base_t;
class curve_client_t : public curve_mechanism_base_t
class curve_client_t ZMQ_FINAL : public curve_mechanism_base_t
{
public:
curve_client_t (session_base_t *session_, const options_t &options_);
virtual ~curve_client_t ();
~curve_client_t () ZMQ_FINAL;
// mechanism implementation
virtual int next_handshake_command (msg_t *msg_);
virtual int process_handshake_command (msg_t *msg_);
virtual int encode (msg_t *msg_);
virtual int decode (msg_t *msg_);
virtual status_t status () const;
int next_handshake_command (msg_t *msg_) ZMQ_FINAL;
int process_handshake_command (msg_t *msg_) ZMQ_FINAL;
int encode (msg_t *msg_) ZMQ_FINAL;
int decode (msg_t *msg_) ZMQ_FINAL;
status_t status () const ZMQ_FINAL;
private:
enum state_t

View File

@ -61,8 +61,8 @@ class curve_mechanism_base_t : public virtual mechanism_base_t
const char *decode_nonce_prefix_);
// mechanism implementation
virtual int encode (msg_t *msg_);
virtual int decode (msg_t *msg_);
int encode (msg_t *msg_) ZMQ_OVERRIDE;
int decode (msg_t *msg_) ZMQ_OVERRIDE;
protected:
const char *encode_nonce_prefix;

View File

@ -42,20 +42,20 @@ namespace zmq
#pragma warning(push)
#pragma warning(disable : 4250)
#endif
class curve_server_t : public zap_client_common_handshake_t,
public curve_mechanism_base_t
class curve_server_t ZMQ_FINAL : public zap_client_common_handshake_t,
public curve_mechanism_base_t
{
public:
curve_server_t (session_base_t *session_,
const std::string &peer_address_,
const options_t &options_);
virtual ~curve_server_t ();
~curve_server_t () ZMQ_FINAL;
// mechanism implementation
virtual int next_handshake_command (msg_t *msg_);
virtual int process_handshake_command (msg_t *msg_);
virtual int encode (msg_t *msg_);
virtual int decode (msg_t *msg_);
int next_handshake_command (msg_t *msg_) ZMQ_FINAL;
int process_handshake_command (msg_t *msg_) ZMQ_FINAL;
int encode (msg_t *msg_) ZMQ_FINAL;
int decode (msg_t *msg_) ZMQ_FINAL;
private:
// Our secret key (s)

View File

@ -47,21 +47,23 @@ class dealer_t : public socket_base_t
{
public:
dealer_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~dealer_t ();
~dealer_t () ZMQ_OVERRIDE;
protected:
// Overrides of functions from socket_base_t.
void xattach_pipe (zmq::pipe_t *pipe_,
bool subscribe_to_all_,
bool locally_initiated_);
int xsetsockopt (int option_, const void *optval_, size_t optvallen_);
int xsend (zmq::msg_t *msg_);
int xrecv (zmq::msg_t *msg_);
bool xhas_in ();
bool xhas_out ();
void xread_activated (zmq::pipe_t *pipe_);
void xwrite_activated (zmq::pipe_t *pipe_);
void xpipe_terminated (zmq::pipe_t *pipe_);
bool locally_initiated_) ZMQ_FINAL;
int xsetsockopt (int option_,
const void *optval_,
size_t optvallen_) ZMQ_OVERRIDE;
int xsend (zmq::msg_t *msg_) ZMQ_OVERRIDE;
int xrecv (zmq::msg_t *msg_) ZMQ_OVERRIDE;
bool xhas_in () ZMQ_OVERRIDE;
bool xhas_out () ZMQ_OVERRIDE;
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_OVERRIDE;
// Send and recv - knowing which pipe was used.
int sendpipe (zmq::msg_t *msg_, zmq::pipe_t **pipe_);

View File

@ -66,12 +66,10 @@ class decoder_base_t : public i_decoder
_buf = _allocator.allocate ();
}
// The destructor doesn't have to be virtual. It is made virtual
// just to keep ICC and code checking tools from complaining.
virtual ~decoder_base_t () { _allocator.deallocate (); }
~decoder_base_t () ZMQ_OVERRIDE { _allocator.deallocate (); }
// Returns a buffer to be filled with binary data.
void get_buffer (unsigned char **data_, std::size_t *size_)
void get_buffer (unsigned char **data_, std::size_t *size_) ZMQ_FINAL
{
_buf = _allocator.allocate ();
@ -101,7 +99,7 @@ class decoder_base_t : public i_decoder
// Number of bytes processed is returned in bytes_used_.
int decode (const unsigned char *data_,
std::size_t size_,
std::size_t &bytes_used_)
std::size_t &bytes_used_) ZMQ_FINAL
{
bytes_used_ = 0;
@ -149,7 +147,7 @@ class decoder_base_t : public i_decoder
return 0;
}
virtual void resize_buffer (std::size_t new_size_)
void resize_buffer (std::size_t new_size_) ZMQ_FINAL
{
_allocator.resize (new_size_);
}

View File

@ -47,13 +47,13 @@ struct i_poll_events;
// Implements socket polling mechanism using the "/dev/poll" interface.
class devpoll_t : public worker_poller_base_t
class devpoll_t ZMQ_FINAL : public worker_poller_base_t
{
public:
typedef fd_t handle_t;
devpoll_t (const thread_ctx_t &ctx_);
~devpoll_t ();
~devpoll_t () ZMQ_FINAL;
// "poller" concept.
handle_t add_fd (fd_t fd_, zmq::i_poll_events *events_);
@ -68,7 +68,7 @@ class devpoll_t : public worker_poller_base_t
private:
// Main event loop.
void loop ();
void loop () ZMQ_FINAL;
// File descriptor referring to "/dev/poll" pseudo-device.
fd_t devpoll_fd;

View File

@ -41,23 +41,23 @@ class msg_t;
class pipe_t;
class io_thread_t;
class dgram_t : public socket_base_t
class dgram_t ZMQ_FINAL : public socket_base_t
{
public:
dgram_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~dgram_t ();
~dgram_t () ZMQ_FINAL;
// Overrides of functions from socket_base_t.
void xattach_pipe (zmq::pipe_t *pipe_,
bool subscribe_to_all_,
bool locally_initiated_);
int xsend (zmq::msg_t *msg_);
int xrecv (zmq::msg_t *msg_);
bool xhas_in ();
bool xhas_out ();
void xread_activated (zmq::pipe_t *pipe_);
void xwrite_activated (zmq::pipe_t *pipe_);
void xpipe_terminated (zmq::pipe_t *pipe_);
bool locally_initiated_) ZMQ_FINAL;
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_in () ZMQ_FINAL;
bool xhas_out () ZMQ_FINAL;
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
private:
zmq::pipe_t *_pipe;

View File

@ -44,27 +44,27 @@ class ctx_t;
class pipe_t;
class io_thread_t;
class dish_t : public socket_base_t
class dish_t ZMQ_FINAL : public socket_base_t
{
public:
dish_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~dish_t ();
~dish_t () ZMQ_FINAL;
protected:
// Overrides of functions from socket_base_t.
void xattach_pipe (zmq::pipe_t *pipe_,
bool subscribe_to_all_,
bool locally_initiated_);
int xsend (zmq::msg_t *msg_);
bool xhas_out ();
int xrecv (zmq::msg_t *msg_);
bool xhas_in ();
void xread_activated (zmq::pipe_t *pipe_);
void xwrite_activated (zmq::pipe_t *pipe_);
void xhiccuped (pipe_t *pipe_);
void xpipe_terminated (zmq::pipe_t *pipe_);
int xjoin (const char *group_);
int xleave (const char *group_);
bool locally_initiated_) ZMQ_FINAL;
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_out () ZMQ_FINAL;
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_in () ZMQ_FINAL;
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xhiccuped (pipe_t *pipe_) ZMQ_FINAL;
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
int xjoin (const char *group_) ZMQ_FINAL;
int xleave (const char *group_) ZMQ_FINAL;
private:
int xxrecv (zmq::msg_t *msg_);
@ -90,7 +90,7 @@ class dish_t : public socket_base_t
ZMQ_NON_COPYABLE_NOR_MOVABLE (dish_t)
};
class dish_session_t : public session_base_t
class dish_session_t ZMQ_FINAL : public session_base_t
{
public:
dish_session_t (zmq::io_thread_t *io_thread_,
@ -98,12 +98,12 @@ class dish_session_t : public session_base_t
zmq::socket_base_t *socket_,
const options_t &options_,
address_t *addr_);
~dish_session_t ();
~dish_session_t () ZMQ_FINAL;
// Overrides of the functions from session_base_t.
int push_msg (msg_t *msg_);
int pull_msg (msg_t *msg_);
void reset ();
int push_msg (msg_t *msg_) ZMQ_FINAL;
int pull_msg (msg_t *msg_) ZMQ_FINAL;
void reset () ZMQ_FINAL;
private:
enum

View File

@ -66,14 +66,12 @@ template <typename T> class encoder_base_t : public i_encoder
alloc_assert (_buf);
}
// The destructor doesn't have to be virtual. It is made virtual
// just to keep ICC and code checking tools from complaining.
inline virtual ~encoder_base_t () { free (_buf); }
inline ~encoder_base_t () ZMQ_OVERRIDE { free (_buf); }
// The function returns a batch of binary data. The data
// are filled to a supplied buffer. If no buffer is supplied (data_
// points to NULL) decoder object will provide buffer of its own.
inline size_t encode (unsigned char **data_, size_t size_)
inline size_t encode (unsigned char **data_, size_t size_) ZMQ_FINAL
{
unsigned char *buffer = !*data_ ? _buf : *data_;
size_t buffersize = !*data_ ? _buf_size : size_;
@ -128,7 +126,7 @@ template <typename T> class encoder_base_t : public i_encoder
return pos;
}
void load_msg (msg_t *msg_)
void load_msg (msg_t *msg_) ZMQ_FINAL
{
zmq_assert (in_progress () == NULL);
_in_progress = msg_;

View File

@ -55,13 +55,13 @@ struct i_poll_events;
// This class implements socket polling mechanism using the Linux-specific
// epoll mechanism.
class epoll_t : public worker_poller_base_t
class epoll_t ZMQ_FINAL : public worker_poller_base_t
{
public:
typedef void *handle_t;
epoll_t (const thread_ctx_t &ctx_);
~epoll_t ();
~epoll_t () ZMQ_OVERRIDE;
// "poller" concept.
handle_t add_fd (fd_t fd_, zmq::i_poll_events *events_);
@ -87,7 +87,7 @@ class epoll_t : public worker_poller_base_t
#endif
// Main event loop.
void loop ();
void loop () ZMQ_FINAL;
// Main epoll file descriptor
epoll_fd_t _epoll_fd;

View File

@ -39,21 +39,21 @@ class ctx_t;
class pipe_t;
class msg_t;
class gather_t : public socket_base_t
class gather_t ZMQ_FINAL : public socket_base_t
{
public:
gather_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~gather_t ();
~gather_t () ZMQ_FINAL;
protected:
// Overrides of functions from socket_base_t.
void xattach_pipe (zmq::pipe_t *pipe_,
bool subscribe_to_all_,
bool locally_initiated_);
int xrecv (zmq::msg_t *msg_);
bool xhas_in ();
void xread_activated (zmq::pipe_t *pipe_);
void xpipe_terminated (zmq::pipe_t *pipe_);
bool locally_initiated_) ZMQ_FINAL;
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_in () ZMQ_FINAL;
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
private:
// Fair queueing object for inbound pipes.

View File

@ -39,18 +39,18 @@ namespace zmq
class msg_t;
class session_base_t;
class gssapi_client_t : public gssapi_mechanism_base_t
class gssapi_client_t ZMQ_FINAL : public gssapi_mechanism_base_t
{
public:
gssapi_client_t (session_base_t *session_, const options_t &options_);
virtual ~gssapi_client_t ();
~gssapi_client_t () ZMQ_FINAL;
// mechanism implementation
virtual int next_handshake_command (msg_t *msg_);
virtual int process_handshake_command (msg_t *msg_);
virtual int encode (msg_t *msg_);
virtual int decode (msg_t *msg_);
virtual status_t status () const;
int next_handshake_command (msg_t *msg_) ZMQ_FINAL;
int process_handshake_command (msg_t *msg_) ZMQ_FINAL;
int encode (msg_t *msg_) ZMQ_FINAL;
int decode (msg_t *msg_) ZMQ_FINAL;
status_t status () const ZMQ_FINAL;
private:
enum state_t

View File

@ -53,7 +53,7 @@ class gssapi_mechanism_base_t : public virtual mechanism_base_t
public:
gssapi_mechanism_base_t (session_base_t *session_,
const options_t &options_);
virtual ~gssapi_mechanism_base_t () = 0;
~gssapi_mechanism_base_t () ZMQ_OVERRIDE = 0;
protected:
// Produce a context-level GSSAPI token (INITIATE command)

View File

@ -40,21 +40,22 @@ namespace zmq
class msg_t;
class session_base_t;
class gssapi_server_t : public gssapi_mechanism_base_t, public zap_client_t
class gssapi_server_t ZMQ_FINAL : public gssapi_mechanism_base_t,
public zap_client_t
{
public:
gssapi_server_t (session_base_t *session_,
const std::string &peer_address,
const options_t &options_);
virtual ~gssapi_server_t ();
~gssapi_server_t () ZMQ_FINAL;
// mechanism implementation
virtual int next_handshake_command (msg_t *msg_);
virtual int process_handshake_command (msg_t *msg_);
virtual int encode (msg_t *msg_);
virtual int decode (msg_t *msg_);
virtual int zap_msg_available ();
virtual status_t status () const;
int next_handshake_command (msg_t *msg_) ZMQ_FINAL;
int process_handshake_command (msg_t *msg_) ZMQ_FINAL;
int encode (msg_t *msg_) ZMQ_FINAL;
int decode (msg_t *msg_) ZMQ_FINAL;
int zap_msg_available () ZMQ_FINAL;
status_t status () const ZMQ_FINAL;
private:
enum state_t

View File

@ -48,7 +48,7 @@ class io_object_t : public i_poll_events
{
public:
io_object_t (zmq::io_thread_t *io_thread_ = NULL);
~io_object_t ();
~io_object_t () ZMQ_OVERRIDE;
// When migrating an object from one I/O thread to another, first
// unplug it, then migrate it, then plug it to the new thread.
@ -69,9 +69,9 @@ class io_object_t : public i_poll_events
void cancel_timer (int id_);
// i_poll_events interface implementation.
void in_event ();
void out_event ();
void timer_event (int id_);
void in_event () ZMQ_OVERRIDE;
void out_event () ZMQ_OVERRIDE;
void timer_event (int id_) ZMQ_OVERRIDE;
private:
poller_t *_poller;

View File

@ -43,14 +43,14 @@ class ctx_t;
// Generic part of the I/O thread. Polling-mechanism-specific features
// are implemented in separate "polling objects".
class io_thread_t : public object_t, public i_poll_events
class io_thread_t ZMQ_FINAL : public object_t, public i_poll_events
{
public:
io_thread_t (zmq::ctx_t *ctx_, uint32_t tid_);
// Clean-up. If the thread was started, it's necessary to call 'stop'
// before invoking destructor. Otherwise the destructor would hang up.
~io_thread_t ();
~io_thread_t () ZMQ_FINAL;
// Launch the physical thread.
void start ();
@ -62,15 +62,15 @@ class io_thread_t : public object_t, public i_poll_events
mailbox_t *get_mailbox ();
// i_poll_events implementation.
void in_event ();
void out_event ();
void timer_event (int id_);
void in_event () ZMQ_FINAL;
void out_event () ZMQ_FINAL;
void timer_event (int id_) ZMQ_FINAL;
// Used by io_objects to retrieve the associated poller object.
poller_t *get_poller ();
// Command handlers.
void process_stop ();
void process_stop () ZMQ_FINAL;
// Returns load experienced by the I/O thread.
int get_load ();

View File

@ -37,7 +37,7 @@
namespace zmq
{
class ipc_connecter_t : public stream_connecter_base_t
class ipc_connecter_t ZMQ_FINAL : public stream_connecter_base_t
{
public:
// If 'delayed_start' is true connecter first waits for a while,
@ -50,10 +50,10 @@ class ipc_connecter_t : public stream_connecter_base_t
private:
// Handlers for I/O events.
void out_event ();
void out_event () ZMQ_FINAL;
// Internal function to start the actual connection establishment.
void start_connecting ();
void start_connecting () ZMQ_FINAL;
// Open IPC connecting socket. Returns -1 in case of error,
// 0 if connect was successful immediately. Returns -1 with

View File

@ -39,7 +39,7 @@
namespace zmq
{
class ipc_listener_t : public stream_listener_base_t
class ipc_listener_t ZMQ_FINAL : public stream_listener_base_t
{
public:
ipc_listener_t (zmq::io_thread_t *io_thread_,
@ -50,11 +50,12 @@ class ipc_listener_t : public stream_listener_base_t
int set_local_address (const char *addr_);
protected:
std::string get_socket_name (fd_t fd_, socket_end_t socket_end_) const;
std::string get_socket_name (fd_t fd_,
socket_end_t socket_end_) const ZMQ_FINAL;
private:
// Handlers for I/O events.
void in_event ();
void in_event () ZMQ_FINAL;
// Filter new connections if the OS provides a mechanism to get
// the credentials of the peer process. Called from accept().
@ -62,7 +63,7 @@ class ipc_listener_t : public stream_listener_base_t
bool filter (fd_t sock_);
#endif
int close ();
int close () ZMQ_FINAL;
// Accept the new connection. Returns the file descriptor of the
// newly created connection. The function may return retired_fd

View File

@ -49,13 +49,13 @@ struct i_poll_events;
// Implements socket polling mechanism using the BSD-specific
// kqueue interface.
class kqueue_t : public worker_poller_base_t
class kqueue_t ZMQ_FINAL : public worker_poller_base_t
{
public:
typedef void *handle_t;
kqueue_t (const thread_ctx_t &ctx_);
~kqueue_t ();
~kqueue_t () ZMQ_FINAL;
// "poller" concept.
handle_t add_fd (fd_t fd_, zmq::i_poll_events *events_);
@ -70,7 +70,7 @@ class kqueue_t : public worker_poller_base_t
private:
// Main event loop.
void loop ();
void loop () ZMQ_FINAL;
// File descriptor referring to the kernel event queue.
fd_t kqueue_fd;

View File

@ -20,6 +20,22 @@
#endif
#endif
#if !defined ZMQ_OVERRIDE
#if defined ZMQ_HAVE_NOEXCEPT
#define ZMQ_OVERRIDE override
#else
#define ZMQ_OVERRIDE
#endif
#endif
#if !defined ZMQ_FINAL
#if defined ZMQ_HAVE_NOEXCEPT
#define ZMQ_FINAL final
#else
#define ZMQ_FINAL
#endif
#endif
#if !defined ZMQ_DEFAULT
#if defined ZMQ_HAVE_NOEXCEPT
#define ZMQ_DEFAULT = default;

View File

@ -42,15 +42,15 @@
namespace zmq
{
class mailbox_t : public i_mailbox
class mailbox_t ZMQ_FINAL : public i_mailbox
{
public:
mailbox_t ();
~mailbox_t ();
~mailbox_t () ZMQ_FINAL;
fd_t get_fd () const;
void send (const command_t &cmd_);
int recv (command_t *cmd_, int timeout_);
void send (const command_t &cmd_) ZMQ_FINAL;
int recv (command_t *cmd_, int timeout_) ZMQ_FINAL;
bool valid () const;
@ -58,7 +58,7 @@ class mailbox_t : public i_mailbox
// close the file descriptors in the signaller. This is used in a forked
// child process to close the file descriptors so that they do not interfere
// with the context in the parent process.
void forked () { _signaler.forked (); }
void forked () ZMQ_FINAL { _signaler.forked (); }
#endif
private:

View File

@ -44,14 +44,14 @@
namespace zmq
{
class mailbox_safe_t : public i_mailbox
class mailbox_safe_t ZMQ_FINAL : public i_mailbox
{
public:
mailbox_safe_t (mutex_t *sync_);
~mailbox_safe_t ();
~mailbox_safe_t () ZMQ_FINAL;
void send (const command_t &cmd_);
int recv (command_t *cmd_, int timeout_);
void send (const command_t &cmd_) ZMQ_FINAL;
int recv (command_t *cmd_, int timeout_) ZMQ_FINAL;
// Add signaler to mailbox which will be called when a message is ready
void add_signaler (signaler_t *signaler_);
@ -62,7 +62,7 @@ class mailbox_safe_t : public i_mailbox
// close the file descriptors in the signaller. This is used in a forked
// child process to close the file descriptors so that they do not interfere
// with the context in the parent process.
void forked ()
void forked () ZMQ_FINAL
{
// TODO: call fork on the condition variable
}

View File

@ -18,11 +18,11 @@ class io_thread_t;
class msg_t;
class session_base_t;
class norm_engine_t : public io_object_t, public i_engine
class norm_engine_t ZMQ_FINAL : public io_object_t, public i_engine
{
public:
norm_engine_t (zmq::io_thread_t *parent_, const options_t &options_);
~norm_engine_t ();
~norm_engine_t () ZMQ_FINAL;
// create NORM instance, session, etc
int init (const char *network_, bool send, bool recv);
@ -30,24 +30,24 @@ class norm_engine_t : public io_object_t, public i_engine
// i_engine interface implementation.
// Plug the engine to the session.
virtual void plug (zmq::io_thread_t *io_thread_,
class session_base_t *session_);
void plug (zmq::io_thread_t *io_thread_,
class session_base_t *session_) ZMQ_FINAL;
// Terminate and deallocate the engine. Note that 'detached'
// events are not fired on termination.
virtual void terminate ();
void terminate () ZMQ_FINAL;
// This method is called by the session to signalise that more
// messages can be written to the pipe.
virtual bool restart_input ();
bool restart_input () ZMQ_FINAL;
// This method is called by the session to signalise that there
// are messages to send available.
virtual void restart_output ();
void restart_output () ZMQ_FINAL;
virtual void zap_msg_available (){};
void zap_msg_available () ZMQ_FINAL {}
virtual const endpoint_uri_pair_t &get_endpoint () const;
const endpoint_uri_pair_t &get_endpoint () const ZMQ_FINAL;
// i_poll_events interface implementation.
// (we only need in_event() for NormEvent notification)

View File

@ -39,19 +39,19 @@ namespace zmq
class msg_t;
class session_base_t;
class null_mechanism_t : public zap_client_t
class null_mechanism_t ZMQ_FINAL : public zap_client_t
{
public:
null_mechanism_t (session_base_t *session_,
const std::string &peer_address_,
const options_t &options_);
virtual ~null_mechanism_t ();
~null_mechanism_t () ZMQ_FINAL;
// mechanism implementation
virtual int next_handshake_command (msg_t *msg_);
virtual int process_handshake_command (msg_t *msg_);
virtual int zap_msg_available ();
virtual status_t status () const;
int next_handshake_command (msg_t *msg_) ZMQ_FINAL;
int process_handshake_command (msg_t *msg_) ZMQ_FINAL;
int zap_msg_available () ZMQ_FINAL;
status_t status () const ZMQ_FINAL;
private:
bool _ready_command_sent;

View File

@ -90,12 +90,12 @@ class own_t : public object_t
// others to invoke the destructor. At the same time, it has to be
// virtual so that generic own_t deallocation mechanism destroys
// specific type of the owned object correctly.
virtual ~own_t ();
~own_t () ZMQ_OVERRIDE;
// Term handler is protected rather than private so that it can
// be intercepted by the derived class. This is useful to add custom
// steps to the beginning of the termination process.
void process_term (int linger_);
void process_term (int linger_) ZMQ_OVERRIDE;
// A place to hook in when physical destruction of the object
// is to be delayed.
@ -109,10 +109,10 @@ class own_t : public object_t
void set_owner (own_t *owner_);
// Handlers for incoming commands.
void process_own (own_t *object_);
void process_term_req (own_t *object_);
void process_term_ack ();
void process_seqnum ();
void process_own (own_t *object_) ZMQ_OVERRIDE;
void process_term_req (own_t *object_) ZMQ_OVERRIDE;
void process_term_ack () ZMQ_OVERRIDE;
void process_seqnum () ZMQ_OVERRIDE;
// Check whether all the pending term acks were delivered.
// If so, deallocate this object.

View File

@ -41,23 +41,23 @@ class msg_t;
class pipe_t;
class io_thread_t;
class pair_t : public socket_base_t
class pair_t ZMQ_FINAL : public socket_base_t
{
public:
pair_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~pair_t ();
~pair_t () ZMQ_FINAL;
// Overrides of functions from socket_base_t.
void xattach_pipe (zmq::pipe_t *pipe_,
bool subscribe_to_all_,
bool locally_initiated_);
int xsend (zmq::msg_t *msg_);
int xrecv (zmq::msg_t *msg_);
bool xhas_in ();
bool xhas_out ();
void xread_activated (zmq::pipe_t *pipe_);
void xwrite_activated (zmq::pipe_t *pipe_);
void xpipe_terminated (zmq::pipe_t *pipe_);
bool locally_initiated_) ZMQ_FINAL;
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_in () ZMQ_FINAL;
bool xhas_out () ZMQ_FINAL;
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
private:
zmq::pipe_t *_pipe;

View File

@ -46,7 +46,7 @@ namespace zmq
class io_thread_t;
class session_base_t;
class pgm_receiver_t : public io_object_t, public i_engine
class pgm_receiver_t ZMQ_FINAL : public io_object_t, public i_engine
{
public:
pgm_receiver_t (zmq::io_thread_t *parent_, const options_t &options_);

View File

@ -45,7 +45,7 @@ namespace zmq
class io_thread_t;
class session_base_t;
class pgm_sender_t : public io_object_t, public i_engine
class pgm_sender_t ZMQ_FINAL : public io_object_t, public i_engine
{
public:
pgm_sender_t (zmq::io_thread_t *parent_, const options_t &options_);

View File

@ -71,10 +71,10 @@ struct i_pipe_events
// The array of inbound pipes (1), the array of outbound pipes (2) and
// the generic array of pipes to be deallocated (3).
class pipe_t : public object_t,
public array_item_t<1>,
public array_item_t<2>,
public array_item_t<3>
class pipe_t ZMQ_FINAL : public object_t,
public array_item_t<1>,
public array_item_t<2>,
public array_item_t<3>
{
// This allows pipepair to create pipe objects.
friend int pipepair (zmq::object_t *parents_[2],
@ -152,15 +152,16 @@ class pipe_t : public object_t,
typedef ypipe_base_t<msg_t> upipe_t;
// Command handlers.
void process_activate_read ();
void process_activate_write (uint64_t msgs_read_);
void process_hiccup (void *pipe_);
void process_pipe_peer_stats (uint64_t queue_count_,
own_t *socket_base_,
endpoint_uri_pair_t *endpoint_pair_);
void process_pipe_term ();
void process_pipe_term_ack ();
void process_pipe_hwm (int inhwm_, int outhwm_);
void process_activate_read () ZMQ_OVERRIDE;
void process_activate_write (uint64_t msgs_read_) ZMQ_OVERRIDE;
void process_hiccup (void *pipe_) ZMQ_OVERRIDE;
void
process_pipe_peer_stats (uint64_t queue_count_,
own_t *socket_base_,
endpoint_uri_pair_t *endpoint_pair_) ZMQ_OVERRIDE;
void process_pipe_term () ZMQ_OVERRIDE;
void process_pipe_term_ack () ZMQ_OVERRIDE;
void process_pipe_hwm (int inhwm_, int outhwm_) ZMQ_OVERRIDE;
// Handler for delimiter read from the pipe.
void process_delimiter ();
@ -179,7 +180,7 @@ class pipe_t : public object_t,
void set_peer (pipe_t *peer_);
// Destructor is private. Pipe objects destroy themselves.
~pipe_t ();
~pipe_t () ZMQ_OVERRIDE;
// Underlying pipes for both directions.
upipe_t *_in_pipe;

View File

@ -37,16 +37,16 @@ namespace zmq
{
class msg_t;
class plain_client_t : public mechanism_base_t
class plain_client_t ZMQ_FINAL : public mechanism_base_t
{
public:
plain_client_t (session_base_t *const session_, const options_t &options_);
virtual ~plain_client_t ();
~plain_client_t () ZMQ_FINAL;
// mechanism implementation
virtual int next_handshake_command (msg_t *msg_);
virtual int process_handshake_command (msg_t *msg_);
virtual status_t status () const;
int next_handshake_command (msg_t *msg_) ZMQ_FINAL;
int process_handshake_command (msg_t *msg_) ZMQ_FINAL;
status_t status () const ZMQ_FINAL;
private:
enum state_t

View File

@ -38,17 +38,17 @@ namespace zmq
class msg_t;
class session_base_t;
class plain_server_t : public zap_client_common_handshake_t
class plain_server_t ZMQ_FINAL : public zap_client_common_handshake_t
{
public:
plain_server_t (session_base_t *session_,
const std::string &peer_address_,
const options_t &options_);
virtual ~plain_server_t ();
~plain_server_t () ZMQ_FINAL;
// mechanism implementation
virtual int next_handshake_command (msg_t *msg_);
virtual int process_handshake_command (msg_t *msg_);
int next_handshake_command (msg_t *msg_) ZMQ_FINAL;
int process_handshake_command (msg_t *msg_) ZMQ_FINAL;
private:
void produce_welcome (msg_t *msg_) const;

View File

@ -56,7 +56,7 @@ struct i_poll_events;
// Implements socket polling mechanism using the POSIX.1-2001
// poll() system call.
class poll_t : public worker_poller_base_t
class poll_t ZMQ_FINAL : public worker_poller_base_t
{
public:
typedef fd_t handle_t;
@ -78,7 +78,7 @@ class poll_t : public worker_poller_base_t
private:
// Main event loop.
virtual void loop ();
void loop () ZMQ_FINAL;
void cleanup_retired ();

View File

@ -32,10 +32,6 @@
#include "i_poll_events.hpp"
#include "err.hpp"
zmq::poller_base_t::poller_base_t ()
{
}
zmq::poller_base_t::~poller_base_t ()
{
// Make sure there is no more load on the shutdown.

View File

@ -114,7 +114,7 @@ struct i_poll_events;
// a container that is being iterated by the poller.
// A class that can be used as a base class for implementations of the poller
// A class that can be used as abase class for implementations of the poller
// concept.
//
// For documentation of the public methods, see the description of the poller_t
@ -122,7 +122,7 @@ struct i_poll_events;
class poller_base_t
{
public:
poller_base_t ();
poller_base_t () ZMQ_DEFAULT;
virtual ~poller_base_t ();
// Methods from the poller concept.

View File

@ -50,13 +50,13 @@ struct i_poll_events;
// This class implements socket polling mechanism using the AIX-specific
// pollset mechanism.
class pollset_t : public poller_base_t
class pollset_t ZMQ_FINAL : public poller_base_t
{
public:
typedef void *handle_t;
pollset_t (const thread_ctx_t &ctx_);
~pollset_t ();
~pollset_t () ZMQ_FINAL;
// "poller" concept.
handle_t add_fd (fd_t fd_, zmq::i_poll_events *events_);
@ -75,7 +75,7 @@ class pollset_t : public poller_base_t
static void worker_routine (void *arg_);
// Main event loop.
void loop ();
void loop () ZMQ_FINAL;
// Reference to ZMQ context.
const thread_ctx_t &ctx;

View File

@ -39,18 +39,18 @@ class io_thread_t;
class socket_base_t;
class msg_t;
class pub_t : public xpub_t
class pub_t ZMQ_FINAL : public xpub_t
{
public:
pub_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~pub_t ();
~pub_t () ZMQ_FINAL;
// Implementations of virtual functions from socket_base_t.
void xattach_pipe (zmq::pipe_t *pipe_,
bool subscribe_to_all_ = false,
bool locally_initiated_ = false);
int xrecv (zmq::msg_t *msg_);
bool xhas_in ();
bool locally_initiated_ = false) ZMQ_FINAL;
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_in () ZMQ_FINAL;
ZMQ_NON_COPYABLE_NOR_MOVABLE (pub_t)
};

View File

@ -41,21 +41,21 @@ class pipe_t;
class msg_t;
class io_thread_t;
class pull_t : public socket_base_t
class pull_t ZMQ_FINAL : public socket_base_t
{
public:
pull_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~pull_t ();
~pull_t () ZMQ_FINAL;
protected:
// Overrides of functions from socket_base_t.
void xattach_pipe (zmq::pipe_t *pipe_,
bool subscribe_to_all_,
bool locally_initiated_);
int xrecv (zmq::msg_t *msg_);
bool xhas_in ();
void xread_activated (zmq::pipe_t *pipe_);
void xpipe_terminated (zmq::pipe_t *pipe_);
bool locally_initiated_) ZMQ_FINAL;
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_in () ZMQ_FINAL;
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
private:
// Fair queueing object for inbound pipes.

View File

@ -41,21 +41,21 @@ class pipe_t;
class msg_t;
class io_thread_t;
class push_t : public socket_base_t
class push_t ZMQ_FINAL : public socket_base_t
{
public:
push_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~push_t ();
~push_t () ZMQ_FINAL;
protected:
// Overrides of functions from socket_base_t.
void xattach_pipe (zmq::pipe_t *pipe_,
bool subscribe_to_all_,
bool locally_initiated_);
int xsend (zmq::msg_t *msg_);
bool xhas_out ();
void xwrite_activated (zmq::pipe_t *pipe_);
void xpipe_terminated (zmq::pipe_t *pipe_);
bool locally_initiated_) ZMQ_FINAL;
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_out () ZMQ_FINAL;
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
private:
// Load balancer managing the outbound pipes.

View File

@ -45,24 +45,25 @@ class ctx_t;
class pipe_t;
class io_thread_t;
class radio_t : public socket_base_t
class radio_t ZMQ_FINAL : public socket_base_t
{
public:
radio_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~radio_t ();
~radio_t () ZMQ_FINAL;
// Implementations of virtual functions from socket_base_t.
void xattach_pipe (zmq::pipe_t *pipe_,
bool subscribe_to_all_ = false,
bool locally_initiated_ = false);
int xsend (zmq::msg_t *msg_);
bool xhas_out ();
int xrecv (zmq::msg_t *msg_);
bool xhas_in ();
void xread_activated (zmq::pipe_t *pipe_);
void xwrite_activated (zmq::pipe_t *pipe_);
int xsetsockopt (int option_, const void *optval_, size_t optvallen_);
void xpipe_terminated (zmq::pipe_t *pipe_);
bool locally_initiated_ = false) ZMQ_FINAL;
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_out () ZMQ_FINAL;
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_in () ZMQ_FINAL;
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
int
xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_FINAL;
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
private:
// List of all subscriptions mapped to corresponding pipes.
@ -82,7 +83,7 @@ class radio_t : public socket_base_t
ZMQ_NON_COPYABLE_NOR_MOVABLE (radio_t)
};
class radio_session_t : public session_base_t
class radio_session_t ZMQ_FINAL : public session_base_t
{
public:
radio_session_t (zmq::io_thread_t *io_thread_,
@ -90,12 +91,12 @@ class radio_session_t : public session_base_t
zmq::socket_base_t *socket_,
const options_t &options_,
address_t *addr_);
~radio_session_t ();
~radio_session_t () ZMQ_FINAL;
// Overrides of the functions from session_base_t.
int push_msg (msg_t *msg_);
int pull_msg (msg_t *msg_);
void reset ();
int push_msg (msg_t *msg_) ZMQ_FINAL;
int pull_msg (msg_t *msg_) ZMQ_FINAL;
void reset () ZMQ_FINAL;
private:
enum

View File

@ -39,22 +39,23 @@ namespace zmq
{
// Decoder for 0MQ v1 framing protocol. Converts data stream into messages.
class raw_decoder_t : public i_decoder
class raw_decoder_t ZMQ_FINAL : public i_decoder
{
public:
raw_decoder_t (size_t bufsize_);
virtual ~raw_decoder_t ();
~raw_decoder_t () ZMQ_FINAL;
// i_decoder interface.
virtual void get_buffer (unsigned char **data_, size_t *size_);
void get_buffer (unsigned char **data_, size_t *size_) ZMQ_FINAL;
virtual int
decode (const unsigned char *data_, size_t size_, size_t &bytes_used_);
int decode (const unsigned char *data_,
size_t size_,
size_t &bytes_used_) ZMQ_FINAL;
virtual msg_t *msg () { return &_in_progress; }
msg_t *msg () ZMQ_FINAL { return &_in_progress; }
virtual void resize_buffer (size_t) {}
void resize_buffer (size_t) ZMQ_FINAL {}
private:
msg_t _in_progress;

View File

@ -40,11 +40,11 @@ namespace zmq
{
// Encoder for 0MQ framing protocol. Converts messages into data batches.
class raw_encoder_t : public encoder_base_t<raw_encoder_t>
class raw_encoder_t ZMQ_FINAL : public encoder_base_t<raw_encoder_t>
{
public:
raw_encoder_t (size_t bufsize_);
~raw_encoder_t ();
~raw_encoder_t () ZMQ_FINAL;
private:
void raw_message_ready ();

View File

@ -54,18 +54,18 @@ class mechanism_t;
// This engine handles any socket with SOCK_STREAM semantics,
// e.g. TCP socket or an UNIX domain socket.
class raw_engine_t : public stream_engine_base_t
class raw_engine_t ZMQ_FINAL : public stream_engine_base_t
{
public:
raw_engine_t (fd_t fd_,
const options_t &options_,
const endpoint_uri_pair_t &endpoint_uri_pair_);
~raw_engine_t ();
~raw_engine_t () ZMQ_FINAL;
protected:
void error (error_reason_t reason_);
void plug_internal ();
bool handshake ();
void error (error_reason_t reason_) ZMQ_FINAL;
void plug_internal () ZMQ_FINAL;
bool handshake () ZMQ_FINAL;
private:
int push_raw_msg_to_session (msg_t *msg_);

View File

@ -40,11 +40,11 @@ namespace zmq
class ctx_t;
class socket_base_t;
class reaper_t : public object_t, public i_poll_events
class reaper_t ZMQ_FINAL : public object_t, public i_poll_events
{
public:
reaper_t (zmq::ctx_t *ctx_, uint32_t tid_);
~reaper_t ();
~reaper_t () ZMQ_FINAL;
mailbox_t *get_mailbox ();
@ -52,15 +52,15 @@ class reaper_t : public object_t, public i_poll_events
void stop ();
// i_poll_events implementation.
void in_event ();
void out_event ();
void timer_event (int id_);
void in_event () ZMQ_FINAL;
void out_event () ZMQ_FINAL;
void timer_event (int id_) ZMQ_FINAL;
private:
// Command handlers.
void process_stop ();
void process_reap (zmq::socket_base_t *socket_);
void process_reaped ();
void process_stop () ZMQ_FINAL;
void process_reap (zmq::socket_base_t *socket_) ZMQ_FINAL;
void process_reaped () ZMQ_FINAL;
// Reaper thread accesses incoming commands via this mailbox.
mailbox_t _mailbox;

View File

@ -39,17 +39,17 @@ class msg_t;
class io_thread_t;
class socket_base_t;
class rep_t : public router_t
class rep_t ZMQ_FINAL : public router_t
{
public:
rep_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~rep_t ();
~rep_t () ZMQ_FINAL;
// Overrides of functions from socket_base_t.
int xsend (zmq::msg_t *msg_);
int xrecv (zmq::msg_t *msg_);
bool xhas_in ();
bool xhas_out ();
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_in () ZMQ_FINAL;
bool xhas_out () ZMQ_FINAL;
private:
// If true, we are in process of sending the reply. If false we are

View File

@ -40,19 +40,20 @@ class msg_t;
class io_thread_t;
class socket_base_t;
class req_t : public dealer_t
class req_t ZMQ_FINAL : public dealer_t
{
public:
req_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~req_t ();
~req_t () ZMQ_FINAL;
// Overrides of functions from socket_base_t.
int xsend (zmq::msg_t *msg_);
int xrecv (zmq::msg_t *msg_);
bool xhas_in ();
bool xhas_out ();
int xsetsockopt (int option_, const void *optval_, size_t optvallen_);
void xpipe_terminated (zmq::pipe_t *pipe_);
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_in () ZMQ_FINAL;
bool xhas_out () ZMQ_FINAL;
int
xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_FINAL;
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
protected:
// Receive only from the pipe the request was sent to, discarding
@ -86,7 +87,7 @@ class req_t : public dealer_t
ZMQ_NON_COPYABLE_NOR_MOVABLE (req_t)
};
class req_session_t : public session_base_t
class req_session_t ZMQ_FINAL : public session_base_t
{
public:
req_session_t (zmq::io_thread_t *io_thread_,
@ -94,11 +95,11 @@ class req_session_t : public session_base_t
zmq::socket_base_t *socket_,
const options_t &options_,
address_t *addr_);
~req_session_t ();
~req_session_t () ZMQ_FINAL;
// Overrides of the functions from session_base_t.
int push_msg (msg_t *msg_);
void reset ();
int push_msg (msg_t *msg_) ZMQ_FINAL;
void reset () ZMQ_FINAL;
private:
enum

View File

@ -49,20 +49,22 @@ class router_t : public routing_socket_base_t
{
public:
router_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~router_t ();
~router_t () ZMQ_OVERRIDE;
// Overrides of functions from socket_base_t.
void xattach_pipe (zmq::pipe_t *pipe_,
bool subscribe_to_all_,
bool locally_initiated_);
int xsetsockopt (int option_, const void *optval_, size_t optvallen_);
int xsend (zmq::msg_t *msg_);
int xrecv (zmq::msg_t *msg_);
bool xhas_in ();
bool xhas_out ();
void xread_activated (zmq::pipe_t *pipe_);
void xpipe_terminated (zmq::pipe_t *pipe_);
int get_peer_state (const void *routing_id_, size_t routing_id_size_) const;
bool locally_initiated_) ZMQ_FINAL;
int
xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_FINAL;
int xsend (zmq::msg_t *msg_) ZMQ_OVERRIDE;
int xrecv (zmq::msg_t *msg_) ZMQ_OVERRIDE;
bool xhas_in () ZMQ_OVERRIDE;
bool xhas_out () ZMQ_OVERRIDE;
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
int get_peer_state (const void *routing_id_,
size_t routing_id_size_) const ZMQ_FINAL;
protected:
// Rollback any message parts that were sent but not yet flushed.

View File

@ -41,21 +41,21 @@ class pipe_t;
class msg_t;
class io_thread_t;
class scatter_t : public socket_base_t
class scatter_t ZMQ_FINAL : public socket_base_t
{
public:
scatter_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~scatter_t ();
~scatter_t () ZMQ_FINAL;
protected:
// Overrides of functions from socket_base_t.
void xattach_pipe (zmq::pipe_t *pipe_,
bool subscribe_to_all_,
bool locally_initiated_);
int xsend (zmq::msg_t *msg_);
bool xhas_out ();
void xwrite_activated (zmq::pipe_t *pipe_);
void xpipe_terminated (zmq::pipe_t *pipe_);
bool locally_initiated_) ZMQ_FINAL;
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_out () ZMQ_FINAL;
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
private:
// Load balancer managing the outbound pipes.

View File

@ -57,13 +57,13 @@ struct i_poll_events;
// Implements socket polling mechanism using POSIX.1-2001 select()
// function.
class select_t : public worker_poller_base_t
class select_t ZMQ_FINAL : public worker_poller_base_t
{
public:
typedef fd_t handle_t;
select_t (const thread_ctx_t &ctx_);
~select_t ();
~select_t () ZMQ_FINAL;
// "poller" concept.
handle_t add_fd (fd_t fd_, zmq::i_poll_events *events_);
@ -78,7 +78,7 @@ class select_t : public worker_poller_base_t
private:
// Main event loop.
void loop ();
void loop () ZMQ_FINAL;
// Internal state.
struct fds_set_t

View File

@ -45,23 +45,23 @@ class msg_t;
class pipe_t;
// TODO: This class uses O(n) scheduling. Rewrite it to use O(1) algorithm.
class server_t : public socket_base_t
class server_t ZMQ_FINAL : public socket_base_t
{
public:
server_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~server_t ();
~server_t () ZMQ_FINAL;
// Overrides of functions from socket_base_t.
void xattach_pipe (zmq::pipe_t *pipe_,
bool subscribe_to_all_,
bool locally_initiated_);
int xsend (zmq::msg_t *msg_);
int xrecv (zmq::msg_t *msg_);
bool xhas_in ();
bool xhas_out ();
void xread_activated (zmq::pipe_t *pipe_);
void xwrite_activated (zmq::pipe_t *pipe_);
void xpipe_terminated (zmq::pipe_t *pipe_);
bool locally_initiated_) ZMQ_FINAL;
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_in () ZMQ_FINAL;
bool xhas_out () ZMQ_FINAL;
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
private:
// Fair queueing object for inbound pipes.

View File

@ -65,10 +65,10 @@ class session_base_t : public own_t, public io_object_t, public i_pipe_events
void engine_error (zmq::i_engine::error_reason_t reason_);
// i_pipe_events interface implementation.
void read_activated (zmq::pipe_t *pipe_);
void write_activated (zmq::pipe_t *pipe_);
void hiccuped (zmq::pipe_t *pipe_);
void pipe_terminated (zmq::pipe_t *pipe_);
void read_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void write_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void hiccuped (zmq::pipe_t *pipe_) ZMQ_FINAL;
void pipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
// Delivers a message. Returns 0 if successful; -1 otherwise.
// The function takes ownership of the message.
@ -101,7 +101,7 @@ class session_base_t : public own_t, public io_object_t, public i_pipe_events
zmq::socket_base_t *socket_,
const options_t &options_,
address_t *addr_);
virtual ~session_base_t ();
~session_base_t () ZMQ_OVERRIDE;
private:
void start_connecting (bool wait_);
@ -138,12 +138,12 @@ class session_base_t : public own_t, public io_object_t, public i_pipe_events
void reconnect ();
// Handlers for incoming commands.
void process_plug ();
void process_attach (zmq::i_engine *engine_);
void process_term (int linger_);
void process_plug () ZMQ_FINAL;
void process_attach (zmq::i_engine *engine_) ZMQ_FINAL;
void process_term (int linger_) ZMQ_FINAL;
// i_poll_events handlers.
void timer_event (int id_);
void timer_event (int id_) ZMQ_FINAL;
// Remove any half processed messages. Flush unflushed messages.
// Call this function when engine disconnect to get rid of leftovers.

View File

@ -107,15 +107,15 @@ class socket_base_t : public own_t,
// i_poll_events implementation. This interface is used when socket
// is handled by the poller in the reaper thread.
void in_event ();
void out_event ();
void timer_event (int id_);
void in_event () ZMQ_FINAL;
void out_event () ZMQ_FINAL;
void timer_event (int id_) ZMQ_FINAL;
// i_pipe_events interface implementation.
void read_activated (pipe_t *pipe_);
void write_activated (pipe_t *pipe_);
void hiccuped (pipe_t *pipe_);
void pipe_terminated (pipe_t *pipe_);
void read_activated (pipe_t *pipe_) ZMQ_FINAL;
void write_activated (pipe_t *pipe_) ZMQ_FINAL;
void hiccuped (pipe_t *pipe_) ZMQ_FINAL;
void pipe_terminated (pipe_t *pipe_) ZMQ_FINAL;
void lock ();
void unlock ();
@ -170,7 +170,7 @@ class socket_base_t : public own_t,
uint32_t tid_,
int sid_,
bool thread_safe_ = false);
virtual ~socket_base_t ();
~socket_base_t () ZMQ_OVERRIDE;
// Concrete algorithms for the x- methods are to be defined by
// individual socket types.
@ -179,7 +179,7 @@ class socket_base_t : public own_t,
bool locally_initiated_ = false) = 0;
// The default implementation assumes there are no specific socket
// options for the particular socket type. If not so, override this
// options for the particular socket type. If not so, ZMQ_FINAL this
// method.
virtual int
xsetsockopt (int option_, const void *optval_, size_t optvallen_);
@ -203,7 +203,7 @@ class socket_base_t : public own_t,
virtual int xleave (const char *group_);
// Delay actual destruction of the socket.
void process_destroy ();
void process_destroy () ZMQ_FINAL;
private:
// test if event should be sent and then dispatch it
@ -284,13 +284,14 @@ class socket_base_t : public own_t,
int process_commands (int timeout_, bool throttle_);
// Handlers for incoming commands.
void process_stop ();
void process_bind (zmq::pipe_t *pipe_);
void process_pipe_stats_publish (uint64_t outbound_queue_count_,
uint64_t inbound_queue_count_,
endpoint_uri_pair_t *endpoint_pair_);
void process_term (int linger_);
void process_term_endpoint (std::string *endpoint_);
void process_stop () ZMQ_FINAL;
void process_bind (zmq::pipe_t *pipe_) ZMQ_FINAL;
void
process_pipe_stats_publish (uint64_t outbound_queue_count_,
uint64_t inbound_queue_count_,
endpoint_uri_pair_t *endpoint_pair_) ZMQ_FINAL;
void process_term (int linger_) ZMQ_FINAL;
void process_term_endpoint (std::string *endpoint_) ZMQ_FINAL;
void update_pipe_options (int option_);
@ -348,12 +349,13 @@ class routing_socket_base_t : public socket_base_t
{
protected:
routing_socket_base_t (class ctx_t *parent_, uint32_t tid_, int sid_);
~routing_socket_base_t ();
~routing_socket_base_t () ZMQ_OVERRIDE;
// methods from socket_base_t
virtual int
xsetsockopt (int option_, const void *optval_, size_t optvallen_);
virtual void xwrite_activated (pipe_t *pipe_);
int xsetsockopt (int option_,
const void *optval_,
size_t optvallen_) ZMQ_OVERRIDE;
void xwrite_activated (pipe_t *pipe_) ZMQ_FINAL;
// own methods
std::string extract_connect_routing_id ();

View File

@ -41,7 +41,7 @@ class io_thread_t;
class session_base_t;
struct address_t;
class socks_connecter_t : public stream_connecter_base_t
class socks_connecter_t ZMQ_FINAL : public stream_connecter_base_t
{
public:
// If 'delayed_start' is true connecter first waits for a while,
@ -52,7 +52,7 @@ class socks_connecter_t : public stream_connecter_base_t
address_t *addr_,
address_t *proxy_addr_,
bool delayed_start_);
~socks_connecter_t ();
~socks_connecter_t () ZMQ_FINAL;
void set_auth_method_basic (const std::string &username,
const std::string &password);
@ -82,11 +82,11 @@ class socks_connecter_t : public stream_connecter_base_t
};
// Handlers for I/O events.
virtual void in_event ();
virtual void out_event ();
void in_event () ZMQ_FINAL;
void out_event () ZMQ_FINAL;
// Internal function to start the actual connection establishment.
void start_connecting ();
void start_connecting () ZMQ_FINAL;
int process_server_response (const socks_choice_t &response_);
int process_server_response (const socks_response_t &response_);

View File

@ -39,23 +39,24 @@ namespace zmq
class ctx_t;
class pipe_t;
class stream_t : public routing_socket_base_t
class stream_t ZMQ_FINAL : public routing_socket_base_t
{
public:
stream_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~stream_t ();
~stream_t () ZMQ_FINAL;
// Overrides of functions from socket_base_t.
void xattach_pipe (zmq::pipe_t *pipe_,
bool subscribe_to_all_,
bool locally_initiated_);
int xsend (zmq::msg_t *msg_);
int xrecv (zmq::msg_t *msg_);
bool xhas_in ();
bool xhas_out ();
void xread_activated (zmq::pipe_t *pipe_);
void xpipe_terminated (zmq::pipe_t *pipe_);
int xsetsockopt (int option_, const void *optval_, size_t optvallen_);
bool locally_initiated_) ZMQ_FINAL;
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_in () ZMQ_FINAL;
bool xhas_out () ZMQ_FINAL;
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
int
xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_FINAL;
private:
// Generate peer's id and update lookup map

View File

@ -51,16 +51,16 @@ class stream_connecter_base_t : public own_t, public io_object_t
address_t *addr_,
bool delayed_start_);
~stream_connecter_base_t ();
~stream_connecter_base_t () ZMQ_OVERRIDE;
protected:
// Handlers for incoming commands.
void process_plug ();
void process_term (int linger_);
void process_plug () ZMQ_FINAL;
void process_term (int linger_) ZMQ_OVERRIDE;
// Handlers for I/O events.
void in_event ();
void timer_event (int id_);
void in_event () ZMQ_OVERRIDE;
void timer_event (int id_) ZMQ_OVERRIDE;
// Internal function to create the engine after connection was established.
virtual void create_engine (fd_t fd, const std::string &local_address_);

View File

@ -58,20 +58,21 @@ class stream_engine_base_t : public io_object_t, public i_engine
stream_engine_base_t (fd_t fd_,
const options_t &options_,
const endpoint_uri_pair_t &endpoint_uri_pair_);
~stream_engine_base_t ();
~stream_engine_base_t () ZMQ_OVERRIDE;
// i_engine interface implementation.
void plug (zmq::io_thread_t *io_thread_, zmq::session_base_t *session_);
void terminate ();
bool restart_input ();
void restart_output ();
void zap_msg_available ();
const endpoint_uri_pair_t &get_endpoint () const;
void plug (zmq::io_thread_t *io_thread_,
zmq::session_base_t *session_) ZMQ_FINAL;
void terminate () ZMQ_FINAL;
bool restart_input () ZMQ_FINAL;
void restart_output () ZMQ_FINAL;
void zap_msg_available () ZMQ_FINAL;
const endpoint_uri_pair_t &get_endpoint () const ZMQ_FINAL;
// i_poll_events interface implementation.
void in_event ();
void out_event ();
void timer_event (int id_);
void in_event () ZMQ_FINAL;
void out_event () ZMQ_FINAL;
void timer_event (int id_) ZMQ_FINAL;
protected:
typedef metadata_t::dict_t properties_t;

View File

@ -49,7 +49,7 @@ class stream_listener_base_t : public own_t, public io_object_t
stream_listener_base_t (zmq::io_thread_t *io_thread_,
zmq::socket_base_t *socket_,
const options_t &options_);
~stream_listener_base_t ();
~stream_listener_base_t () ZMQ_OVERRIDE;
// Get the bound address for use with wildcards
int get_local_address (std::string &addr_) const;
@ -60,8 +60,8 @@ class stream_listener_base_t : public own_t, public io_object_t
private:
// Handlers for incoming commands.
void process_plug ();
void process_term (int linger_);
void process_plug () ZMQ_FINAL;
void process_term (int linger_) ZMQ_FINAL;
protected:
// Close the listening socket.

View File

@ -39,16 +39,17 @@ class msg_t;
class io_thread_t;
class socket_base_t;
class sub_t : public xsub_t
class sub_t ZMQ_FINAL : public xsub_t
{
public:
sub_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~sub_t ();
~sub_t () ZMQ_FINAL;
protected:
int xsetsockopt (int option_, const void *optval_, size_t optvallen_);
int xsend (zmq::msg_t *msg_);
bool xhas_out ();
int
xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_FINAL;
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_out () ZMQ_FINAL;
ZMQ_NON_COPYABLE_NOR_MOVABLE (sub_t)
};

View File

@ -36,7 +36,7 @@
namespace zmq
{
class tcp_connecter_t : public stream_connecter_base_t
class tcp_connecter_t ZMQ_FINAL : public stream_connecter_base_t
{
public:
// If 'delayed_start' is true connecter first waits for a while,
@ -46,7 +46,7 @@ class tcp_connecter_t : public stream_connecter_base_t
const options_t &options_,
address_t *addr_,
bool delayed_start_);
~tcp_connecter_t ();
~tcp_connecter_t () ZMQ_FINAL;
private:
// ID of the timer used to check the connect timeout, must be different from stream_connecter_base_t::reconnect_timer_id.
@ -56,14 +56,14 @@ class tcp_connecter_t : public stream_connecter_base_t
};
// Handlers for incoming commands.
void process_term (int linger_);
void process_term (int linger_) ZMQ_FINAL;
// Handlers for I/O events.
void out_event ();
void timer_event (int id_);
void out_event () ZMQ_FINAL;
void timer_event (int id_) ZMQ_FINAL;
// Internal function to start the actual connection establishment.
void start_connecting ();
void start_connecting () ZMQ_FINAL;
// Internal function to add a connect timer
void add_connect_timer ();

View File

@ -36,7 +36,7 @@
namespace zmq
{
class tcp_listener_t : public stream_listener_base_t
class tcp_listener_t ZMQ_FINAL : public stream_listener_base_t
{
public:
tcp_listener_t (zmq::io_thread_t *io_thread_,
@ -47,11 +47,12 @@ class tcp_listener_t : public stream_listener_base_t
int set_local_address (const char *addr_);
protected:
std::string get_socket_name (fd_t fd_, socket_end_t socket_end_) const;
std::string get_socket_name (fd_t fd_,
socket_end_t socket_end_) const ZMQ_FINAL;
private:
// Handlers for I/O events.
void in_event ();
void in_event () ZMQ_FINAL;
// Accept the new connection. Returns the file descriptor of the
// newly created connection. The function may return retired_fd

View File

@ -39,7 +39,7 @@
namespace zmq
{
class tipc_connecter_t : public stream_connecter_base_t
class tipc_connecter_t ZMQ_FINAL : public stream_connecter_base_t
{
public:
// If 'delayed_start' is true connecter first waits for a while,
@ -52,10 +52,10 @@ class tipc_connecter_t : public stream_connecter_base_t
private:
// Handlers for I/O events.
void out_event ();
void out_event () ZMQ_FINAL;
// Internal function to start the actual connection establishment.
void start_connecting ();
void start_connecting () ZMQ_FINAL;
// Get the file descriptor of newly created connection. Returns
// retired_fd if the connection was unsuccessful.

View File

@ -42,7 +42,7 @@
namespace zmq
{
class tipc_listener_t : public stream_listener_base_t
class tipc_listener_t ZMQ_FINAL : public stream_listener_base_t
{
public:
tipc_listener_t (zmq::io_thread_t *io_thread_,
@ -53,11 +53,12 @@ class tipc_listener_t : public stream_listener_base_t
int set_local_address (const char *addr_);
protected:
std::string get_socket_name (fd_t fd_, socket_end_t socket_end_) const;
std::string get_socket_name (fd_t fd_,
socket_end_t socket_end_) const ZMQ_FINAL;
private:
// Handlers for I/O events.
void in_event ();
void in_event () ZMQ_FINAL;
// Accept the new connection. Returns the file descriptor of the
// newly created connection. The function may return retired_fd

View File

@ -14,36 +14,37 @@ namespace zmq
class io_thread_t;
class session_base_t;
class udp_engine_t : public io_object_t, public i_engine
class udp_engine_t ZMQ_FINAL : public io_object_t, public i_engine
{
public:
udp_engine_t (const options_t &options_);
~udp_engine_t ();
~udp_engine_t () ZMQ_FINAL;
int init (address_t *address_, bool send_, bool recv_);
// i_engine interface implementation.
// Plug the engine to the session.
void plug (zmq::io_thread_t *io_thread_, class session_base_t *session_);
void plug (zmq::io_thread_t *io_thread_,
class session_base_t *session_) ZMQ_FINAL;
// Terminate and deallocate the engine. Note that 'detached'
// events are not fired on termination.
void terminate ();
void terminate () ZMQ_FINAL;
// This method is called by the session to signalise that more
// messages can be written to the pipe.
bool restart_input ();
bool restart_input () ZMQ_FINAL;
// This method is called by the session to signalise that there
// are messages to send available.
void restart_output ();
void restart_output () ZMQ_FINAL;
void zap_msg_available (){};
void zap_msg_available () ZMQ_FINAL{};
void in_event ();
void out_event ();
void in_event () ZMQ_FINAL;
void out_event () ZMQ_FINAL;
const endpoint_uri_pair_t &get_endpoint () const;
const endpoint_uri_pair_t &get_endpoint () const ZMQ_FINAL;
private:
int resolve_raw_address (char *name_, size_t length_);

View File

@ -36,13 +36,13 @@ namespace zmq
{
// Decoder for ZMTP/1.0 protocol. Converts data batches into messages.
class v1_decoder_t : public decoder_base_t<v1_decoder_t>
class v1_decoder_t ZMQ_FINAL : public decoder_base_t<v1_decoder_t>
{
public:
v1_decoder_t (size_t bufsize_, int64_t maxmsgsize_);
~v1_decoder_t ();
~v1_decoder_t () ZMQ_FINAL;
virtual msg_t *msg () { return &_in_progress; }
msg_t *msg () ZMQ_FINAL { return &_in_progress; }
private:
int one_byte_size_ready (unsigned char const *);

View File

@ -36,11 +36,11 @@ namespace zmq
{
// Encoder for ZMTP/1.0 protocol. Converts messages into data batches.
class v1_encoder_t : public encoder_base_t<v1_encoder_t>
class v1_encoder_t ZMQ_FINAL : public encoder_base_t<v1_encoder_t>
{
public:
v1_encoder_t (size_t bufsize_);
~v1_encoder_t ();
~v1_encoder_t () ZMQ_FINAL;
private:
void size_ready ();

View File

@ -38,15 +38,15 @@ namespace zmq
// Decoder for ZMTP/2.x framing protocol. Converts data stream into messages.
// The class has to inherit from shared_message_memory_allocator because
// the base class calls allocate in its constructor.
class v2_decoder_t
class v2_decoder_t ZMQ_FINAL
: public decoder_base_t<v2_decoder_t, shared_message_memory_allocator>
{
public:
v2_decoder_t (size_t bufsize_, int64_t maxmsgsize_, bool zero_copy_);
virtual ~v2_decoder_t ();
~v2_decoder_t () ZMQ_FINAL;
// i_decoder interface.
virtual msg_t *msg () { return &_in_progress; }
msg_t *msg () ZMQ_FINAL { return &_in_progress; }
private:
int flags_ready (unsigned char const *);

View File

@ -36,11 +36,11 @@ namespace zmq
{
// Encoder for 0MQ framing protocol. Converts messages into data stream.
class v2_encoder_t : public encoder_base_t<v2_encoder_t>
class v2_encoder_t ZMQ_FINAL : public encoder_base_t<v2_encoder_t>
{
public:
v2_encoder_t (size_t bufsize_);
virtual ~v2_encoder_t ();
~v2_encoder_t () ZMQ_FINAL;
private:
void size_ready ();

View File

@ -46,7 +46,7 @@ class session_base_t;
struct address_t;
// TODO consider refactoring this to derive from stream_connecter_base_t
class vmci_connecter_t : public own_t, public io_object_t
class vmci_connecter_t ZMQ_FINAL : public own_t, public io_object_t
{
public:
// If 'delayed_start' is true connecter first waits for a while,

View File

@ -47,7 +47,7 @@ class io_thread_t;
class socket_base_t;
// TODO consider refactoring this to derive from stream_listener_base_t
class vmci_listener_t : public own_t, public io_object_t
class vmci_listener_t ZMQ_FINAL : public own_t, public io_object_t
{
public:
vmci_listener_t (zmq::io_thread_t *io_thread_,

View File

@ -36,7 +36,7 @@
namespace zmq
{
class ws_connecter_t : public stream_connecter_base_t
class ws_connecter_t ZMQ_FINAL : public stream_connecter_base_t
{
public:
// If 'delayed_start' is true connecter first waits for a while,
@ -48,10 +48,10 @@ class ws_connecter_t : public stream_connecter_base_t
bool delayed_start_,
bool wss_,
const std::string &tls_hostname_);
~ws_connecter_t ();
~ws_connecter_t () ZMQ_FINAL;
protected:
void create_engine (fd_t fd, const std::string &local_address_);
void create_engine (fd_t fd, const std::string &local_address_) ZMQ_FINAL;
private:
// ID of the timer used to check the connect timeout, must be different from stream_connecter_base_t::reconnect_timer_id.
@ -61,14 +61,14 @@ class ws_connecter_t : public stream_connecter_base_t
};
// Handlers for incoming commands.
void process_term (int linger_);
void process_term (int linger_) ZMQ_FINAL;
// Handlers for I/O events.
void out_event ();
void timer_event (int id_);
void out_event () ZMQ_FINAL;
void timer_event (int id_) ZMQ_FINAL;
// Internal function to start the actual connection establishment.
void start_connecting ();
void start_connecting () ZMQ_FINAL;
// Internal function to add a connect timer
void add_connect_timer ();

View File

@ -39,7 +39,7 @@ namespace zmq
// Decoder for Web socket framing protocol. Converts data stream into messages.
// The class has to inherit from shared_message_memory_allocator because
// the base class calls allocate in its constructor.
class ws_decoder_t
class ws_decoder_t ZMQ_FINAL
: public decoder_base_t<ws_decoder_t, shared_message_memory_allocator>
{
public:
@ -47,10 +47,10 @@ class ws_decoder_t
int64_t maxmsgsize_,
bool zero_copy_,
bool must_mask_);
virtual ~ws_decoder_t ();
~ws_decoder_t () ZMQ_FINAL;
// i_decoder interface.
virtual msg_t *msg () { return &_in_progress; }
msg_t *msg () ZMQ_FINAL { return &_in_progress; }
private:
int opcode_ready (unsigned char const *);

View File

@ -36,11 +36,11 @@ namespace zmq
{
// Encoder for web socket framing protocol. Converts messages into data stream.
class ws_encoder_t : public encoder_base_t<ws_encoder_t>
class ws_encoder_t ZMQ_FINAL : public encoder_base_t<ws_encoder_t>
{
public:
ws_encoder_t (size_t bufsize_, bool must_mask_);
virtual ~ws_encoder_t ();
~ws_encoder_t () ZMQ_FINAL;
private:
void size_ready ();

View File

@ -124,7 +124,7 @@ typedef enum
client_handshake_error = -1
} ws_client_handshake_state_t;
class ws_engine_t : public stream_engine_base_t
class ws_engine_t ZMQ_FINAL : public stream_engine_base_t
{
public:
ws_engine_t (fd_t fd_,
@ -132,7 +132,7 @@ class ws_engine_t : public stream_engine_base_t
const endpoint_uri_pair_t &endpoint_uri_pair_,
ws_address_t &address_,
bool client_);
~ws_engine_t ();
~ws_engine_t () ZMQ_FINAL;
protected:
int decode_and_push (msg_t *msg_);

View File

@ -40,7 +40,7 @@
namespace zmq
{
class ws_listener_t : public stream_listener_base_t
class ws_listener_t ZMQ_FINAL : public stream_listener_base_t
{
public:
ws_listener_t (zmq::io_thread_t *io_thread_,
@ -48,18 +48,19 @@ class ws_listener_t : public stream_listener_base_t
const options_t &options_,
bool wss_);
~ws_listener_t ();
~ws_listener_t () ZMQ_FINAL;
// Set address to listen on.
int set_local_address (const char *addr_);
protected:
std::string get_socket_name (fd_t fd_, socket_end_t socket_end_) const;
void create_engine (fd_t fd);
std::string get_socket_name (fd_t fd_,
socket_end_t socket_end_) const ZMQ_FINAL;
void create_engine (fd_t fd) ZMQ_FINAL;
private:
// Handlers for I/O events.
void in_event ();
void in_event () ZMQ_FINAL;
// Accept the new connection. Returns the file descriptor of the
// newly created connection. The function may return retired_fd

View File

@ -48,20 +48,21 @@ class xpub_t : public socket_base_t
{
public:
xpub_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~xpub_t ();
~xpub_t () ZMQ_OVERRIDE;
// Implementations of virtual functions from socket_base_t.
void xattach_pipe (zmq::pipe_t *pipe_,
bool subscribe_to_all_ = false,
bool locally_initiated_ = false);
int xsend (zmq::msg_t *msg_);
bool xhas_out ();
int xrecv (zmq::msg_t *msg_);
bool xhas_in ();
void xread_activated (zmq::pipe_t *pipe_);
void xwrite_activated (zmq::pipe_t *pipe_);
int xsetsockopt (int option_, const void *optval_, size_t optvallen_);
void xpipe_terminated (zmq::pipe_t *pipe_);
bool locally_initiated_ = false) ZMQ_OVERRIDE;
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_out () ZMQ_FINAL;
int xrecv (zmq::msg_t *msg_) ZMQ_OVERRIDE;
bool xhas_in () ZMQ_OVERRIDE;
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
int
xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_FINAL;
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
private:
// Function to be applied to the trie to send all the subscriptions

View File

@ -50,22 +50,24 @@ class xsub_t : public socket_base_t
{
public:
xsub_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
~xsub_t ();
~xsub_t () ZMQ_OVERRIDE;
protected:
// Overrides of functions from socket_base_t.
void xattach_pipe (zmq::pipe_t *pipe_,
bool subscribe_to_all_,
bool locally_initiated_);
int xsetsockopt (int option_, const void *optval_, size_t optvallen_);
int xsend (zmq::msg_t *msg_);
bool xhas_out ();
int xrecv (zmq::msg_t *msg_);
bool xhas_in ();
void xread_activated (zmq::pipe_t *pipe_);
void xwrite_activated (zmq::pipe_t *pipe_);
void xhiccuped (pipe_t *pipe_);
void xpipe_terminated (zmq::pipe_t *pipe_);
bool locally_initiated_) ZMQ_FINAL;
int xsetsockopt (int option_,
const void *optval_,
size_t optvallen_) ZMQ_OVERRIDE;
int xsend (zmq::msg_t *msg_) ZMQ_OVERRIDE;
bool xhas_out () ZMQ_OVERRIDE;
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
bool xhas_in () ZMQ_FINAL;
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
void xhiccuped (pipe_t *pipe_) ZMQ_FINAL;
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
private:
// Check whether the message matches at least one subscription.

View File

@ -43,7 +43,7 @@ namespace zmq
// N is granularity of the pipe, i.e. how many items are needed to
// perform next memory allocation.
template <typename T, int N> class ypipe_t : public ypipe_base_t<T>
template <typename T, int N> class ypipe_t ZMQ_FINAL : public ypipe_base_t<T>
{
public:
// Initialises the pipe.
@ -71,7 +71,7 @@ template <typename T, int N> class ypipe_t : public ypipe_base_t<T>
// set to true the item is assumed to be continued by items
// subsequently written to the pipe. Incomplete items are never
// flushed down the stream.
inline void write (const T &value_, bool incomplete_)
inline void write (const T &value_, bool incomplete_) ZMQ_FINAL
{
// Place the value to the queue, add new terminator element.
_queue.back () = value_;
@ -88,7 +88,7 @@ template <typename T, int N> class ypipe_t : public ypipe_base_t<T>
// Pop an incomplete item from the pipe. Returns true if such
// item exists, false otherwise.
inline bool unwrite (T *value_)
inline bool unwrite (T *value_) ZMQ_FINAL
{
if (_f == &_queue.back ())
return false;
@ -100,7 +100,7 @@ template <typename T, int N> class ypipe_t : public ypipe_base_t<T>
// Flush all the completed items into the pipe. Returns false if
// the reader thread is sleeping. In that case, caller is obliged to
// wake the reader up before using the pipe again.
inline bool flush ()
inline bool flush () ZMQ_FINAL
{
// If there are no un-flushed items, do nothing.
if (_w == _f)
@ -125,7 +125,7 @@ template <typename T, int N> class ypipe_t : public ypipe_base_t<T>
}
// Check whether item is available for reading.
inline bool check_read ()
inline bool check_read () ZMQ_FINAL
{
// Was the value prefetched already? If so, return.
if (&_queue.front () != _r && _r)
@ -150,7 +150,7 @@ template <typename T, int N> class ypipe_t : public ypipe_base_t<T>
// Reads an item from the pipe. Returns false if there is no value.
// available.
inline bool read (T *value_)
inline bool read (T *value_) ZMQ_FINAL
{
// Try to prefetch a value.
if (!check_read ())
@ -166,7 +166,7 @@ template <typename T, int N> class ypipe_t : public ypipe_base_t<T>
// Applies the function fn to the first elemenent in the pipe
// and returns the value returned by the fn.
// The pipe mustn't be empty or the function crashes.
inline bool probe (bool (*fn_) (const T &))
inline bool probe (bool (*fn_) (const T &)) ZMQ_FINAL
{
bool rc = check_read ();
zmq_assert (rc);

View File

@ -43,7 +43,7 @@ namespace zmq
// reader_awake flag is needed here to mimic ypipe delicate behaviour
// around the reader being asleep (see 'c' pointer being NULL in ypipe.hpp)
template <typename T> class ypipe_conflate_t : public ypipe_base_t<T>
template <typename T> class ypipe_conflate_t ZMQ_FINAL : public ypipe_base_t<T>
{
public:
// Initialises the pipe.
@ -57,7 +57,7 @@ template <typename T> class ypipe_conflate_t : public ypipe_base_t<T>
#pragma message save
#pragma message disable(UNINIT)
#endif
inline void write (const T &value_, bool incomplete_)
inline void write (const T &value_, bool incomplete_) ZMQ_FINAL
{
(void) incomplete_;
@ -69,16 +69,16 @@ template <typename T> class ypipe_conflate_t : public ypipe_base_t<T>
#endif
// There are no incomplete items for conflate ypipe
inline bool unwrite (T *) { return false; }
inline bool unwrite (T *) ZMQ_FINAL { return false; }
// Flush is no-op for conflate ypipe. Reader asleep behaviour
// is as of the usual ypipe.
// Returns false if the reader thread is sleeping. In that case,
// caller is obliged to wake the reader up before using the pipe again.
inline bool flush () { return reader_awake; }
inline bool flush () ZMQ_FINAL { return reader_awake; }
// Check whether item is available for reading.
inline bool check_read ()
inline bool check_read () ZMQ_FINAL
{
bool res = dbuffer.check_read ();
if (!res)
@ -89,7 +89,7 @@ template <typename T> class ypipe_conflate_t : public ypipe_base_t<T>
// Reads an item from the pipe. Returns false if there is no value.
// available.
inline bool read (T *value_)
inline bool read (T *value_) ZMQ_FINAL
{
if (!check_read ())
return false;
@ -100,7 +100,10 @@ template <typename T> class ypipe_conflate_t : public ypipe_base_t<T>
// Applies the function fn to the first elemenent in the pipe
// and returns the value returned by the fn.
// The pipe mustn't be empty or the function crashes.
inline bool probe (bool (*fn_) (const T &)) { return dbuffer.probe (fn_); }
inline bool probe (bool (*fn_) (const T &)) ZMQ_FINAL
{
return dbuffer.probe (fn_);
}
protected:
dbuffer_t<T> dbuffer;

View File

@ -83,12 +83,12 @@ class zap_client_common_handshake_t : public zap_client_t
state_t zap_reply_ok_state_);
// methods from mechanism_t
status_t status () const;
int zap_msg_available ();
status_t status () const ZMQ_FINAL;
int zap_msg_available () ZMQ_FINAL;
// zap_client_t methods
int receive_and_process_zap_reply ();
void handle_zap_status_code ();
int receive_and_process_zap_reply () ZMQ_FINAL;
void handle_zap_status_code () ZMQ_FINAL;
// Current FSM state
state_t state;

View File

@ -59,24 +59,24 @@ class mechanism_t;
// This engine handles any socket with SOCK_STREAM semantics,
// e.g. TCP socket or an UNIX domain socket.
class zmtp_engine_t : public stream_engine_base_t
class zmtp_engine_t ZMQ_FINAL : public stream_engine_base_t
{
public:
zmtp_engine_t (fd_t fd_,
const options_t &options_,
const endpoint_uri_pair_t &endpoint_uri_pair_);
~zmtp_engine_t ();
~zmtp_engine_t () ZMQ_FINAL;
protected:
// Detects the protocol used by the peer.
bool handshake ();
bool handshake () ZMQ_FINAL;
void plug_internal ();
void plug_internal () ZMQ_FINAL;
int process_command_message (msg_t *msg_);
int produce_ping_message (msg_t *msg_);
int process_heartbeat_message (msg_t *msg_);
int produce_pong_message (msg_t *msg_);
int process_command_message (msg_t *msg_) ZMQ_FINAL;
int produce_ping_message (msg_t *msg_) ZMQ_FINAL;
int process_heartbeat_message (msg_t *msg_) ZMQ_FINAL;
int produce_pong_message (msg_t *msg_) ZMQ_FINAL;
private:
// Receive the greeting from the peer.

View File

@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <unity.h>
#include "../src/macros.hpp"
#include "../tests/testutil.hpp"
#include "../tests/testutil_unity.hpp"
#include "../unittests/unittest_resolver_common.hpp"
@ -39,7 +40,7 @@ void tearDown ()
{
}
class test_ip_resolver_t : public zmq::ip_resolver_t
class test_ip_resolver_t ZMQ_FINAL : public zmq::ip_resolver_t
{
public:
test_ip_resolver_t (zmq::ip_resolver_options_t opts_) :
@ -55,10 +56,10 @@ class test_ip_resolver_t : public zmq::ip_resolver_t
const char *ipv6;
};
virtual int do_getaddrinfo (const char *node_,
const char *service_,
const struct addrinfo *hints_,
struct addrinfo **res_)
int do_getaddrinfo (const char *node_,
const char *service_,
const struct addrinfo *hints_,
struct addrinfo **res_) ZMQ_FINAL
{
static const struct dns_lut_t dns_lut[] = {
{"ip.zeromq.org", "10.100.0.1", "fdf5:d058:d656::1"},
@ -105,7 +106,7 @@ class test_ip_resolver_t : public zmq::ip_resolver_t
return zmq::ip_resolver_t::do_getaddrinfo (ip, NULL, &ai, res_);
}
virtual unsigned int do_if_nametoindex (const char *ifname_)
unsigned int do_if_nametoindex (const char *ifname_) ZMQ_FINAL
{
static const char *dummy_interfaces[] = {
"lo0",

View File

@ -63,7 +63,7 @@ struct test_events_t : zmq::i_poll_events
(void) _fd;
}
virtual void in_event ()
void in_event () ZMQ_OVERRIDE
{
_poller.rm_fd (_handle);
_handle = (zmq::poller_t::handle_t) NULL;
@ -73,13 +73,13 @@ struct test_events_t : zmq::i_poll_events
}
virtual void out_event ()
void out_event () ZMQ_OVERRIDE
{
// TODO
}
virtual void timer_event (int id_)
void timer_event (int id_) ZMQ_OVERRIDE
{
LIBZMQ_UNUSED (id_);
_poller.rm_fd (_handle);