mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-25 02:06:06 +02:00
Problem: redundant inline/ZMQ_FINAL declarations
Solution: remove them
This commit is contained in:
@@ -53,15 +53,15 @@ namespace zmq
|
|||||||
template <int ID = 0> class array_item_t
|
template <int ID = 0> class array_item_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline array_item_t () : _array_index (-1) {}
|
array_item_t () : _array_index (-1) {}
|
||||||
|
|
||||||
// The destructor doesn't have to be virtual. It is made virtual
|
// The destructor doesn't have to be virtual. It is made virtual
|
||||||
// just to keep ICC and code checking tools from complaining.
|
// just to keep ICC and code checking tools from complaining.
|
||||||
inline virtual ~array_item_t () ZMQ_DEFAULT;
|
virtual ~array_item_t () ZMQ_DEFAULT;
|
||||||
|
|
||||||
inline void set_array_index (int index_) { _array_index = index_; }
|
void set_array_index (int index_) { _array_index = index_; }
|
||||||
|
|
||||||
inline int get_array_index () const { return _array_index; }
|
int get_array_index () const { return _array_index; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _array_index;
|
int _array_index;
|
||||||
@@ -78,15 +78,15 @@ template <typename T, int ID = 0> class array_t
|
|||||||
public:
|
public:
|
||||||
typedef typename std::vector<T *>::size_type size_type;
|
typedef typename std::vector<T *>::size_type size_type;
|
||||||
|
|
||||||
inline array_t () ZMQ_DEFAULT;
|
array_t () ZMQ_DEFAULT;
|
||||||
|
|
||||||
inline size_type size () { return _items.size (); }
|
size_type size () { return _items.size (); }
|
||||||
|
|
||||||
inline bool empty () { return _items.empty (); }
|
bool empty () { return _items.empty (); }
|
||||||
|
|
||||||
inline T *&operator[] (size_type index_) { return _items[index_]; }
|
T *&operator[] (size_type index_) { return _items[index_]; }
|
||||||
|
|
||||||
inline void push_back (T *item_)
|
void push_back (T *item_)
|
||||||
{
|
{
|
||||||
if (item_)
|
if (item_)
|
||||||
static_cast<item_t *> (item_)->set_array_index (
|
static_cast<item_t *> (item_)->set_array_index (
|
||||||
@@ -94,12 +94,12 @@ template <typename T, int ID = 0> class array_t
|
|||||||
_items.push_back (item_);
|
_items.push_back (item_);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void erase (T *item_)
|
void erase (T *item_)
|
||||||
{
|
{
|
||||||
erase (static_cast<item_t *> (item_)->get_array_index ());
|
erase (static_cast<item_t *> (item_)->get_array_index ());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void erase (size_type index_)
|
void erase (size_type index_)
|
||||||
{
|
{
|
||||||
if (_items.empty ())
|
if (_items.empty ())
|
||||||
return;
|
return;
|
||||||
@@ -110,7 +110,7 @@ template <typename T, int ID = 0> class array_t
|
|||||||
_items.pop_back ();
|
_items.pop_back ();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void swap (size_type index1_, size_type index2_)
|
void swap (size_type index1_, size_type index2_)
|
||||||
{
|
{
|
||||||
if (_items[index1_])
|
if (_items[index1_])
|
||||||
static_cast<item_t *> (_items[index1_])
|
static_cast<item_t *> (_items[index1_])
|
||||||
@@ -121,9 +121,9 @@ template <typename T, int ID = 0> class array_t
|
|||||||
std::swap (_items[index1_], _items[index2_]);
|
std::swap (_items[index1_], _items[index2_]);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void clear () { _items.clear (); }
|
void clear () { _items.clear (); }
|
||||||
|
|
||||||
static inline size_type index (T *item_)
|
static size_type index (T *item_)
|
||||||
{
|
{
|
||||||
return static_cast<size_type> (
|
return static_cast<size_type> (
|
||||||
static_cast<item_t *> (item_)->get_array_index ());
|
static_cast<item_t *> (item_)->get_array_index ());
|
||||||
|
|||||||
@@ -91,16 +91,13 @@ class atomic_counter_t
|
|||||||
public:
|
public:
|
||||||
typedef uint32_t integer_t;
|
typedef uint32_t integer_t;
|
||||||
|
|
||||||
inline atomic_counter_t (integer_t value_ = 0) ZMQ_NOEXCEPT
|
atomic_counter_t (integer_t value_ = 0) ZMQ_NOEXCEPT : _value (value_) {}
|
||||||
: _value (value_)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set counter _value (not thread-safe).
|
// Set counter _value (not thread-safe).
|
||||||
inline void set (integer_t value_) ZMQ_NOEXCEPT { _value = value_; }
|
void set (integer_t value_) ZMQ_NOEXCEPT { _value = value_; }
|
||||||
|
|
||||||
// Atomic addition. Returns the old _value.
|
// Atomic addition. Returns the old _value.
|
||||||
inline integer_t add (integer_t increment_) ZMQ_NOEXCEPT
|
integer_t add (integer_t increment_) ZMQ_NOEXCEPT
|
||||||
{
|
{
|
||||||
integer_t old_value;
|
integer_t old_value;
|
||||||
|
|
||||||
@@ -145,7 +142,7 @@ class atomic_counter_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Atomic subtraction. Returns false if the counter drops to zero.
|
// Atomic subtraction. Returns false if the counter drops to zero.
|
||||||
inline bool sub (integer_t decrement_) ZMQ_NOEXCEPT
|
bool sub (integer_t decrement_) ZMQ_NOEXCEPT
|
||||||
{
|
{
|
||||||
#if defined ZMQ_ATOMIC_COUNTER_WINDOWS
|
#if defined ZMQ_ATOMIC_COUNTER_WINDOWS
|
||||||
LONG delta = -((LONG) decrement_);
|
LONG delta = -((LONG) decrement_);
|
||||||
@@ -200,7 +197,7 @@ class atomic_counter_t
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline integer_t get () const ZMQ_NOEXCEPT { return _value; }
|
integer_t get () const ZMQ_NOEXCEPT { return _value; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined ZMQ_ATOMIC_COUNTER_CXX11
|
#if defined ZMQ_ATOMIC_COUNTER_CXX11
|
||||||
|
|||||||
@@ -178,16 +178,16 @@ template <typename T> class atomic_ptr_t
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Initialise atomic pointer
|
// Initialise atomic pointer
|
||||||
inline atomic_ptr_t () ZMQ_NOEXCEPT { _ptr = NULL; }
|
atomic_ptr_t () ZMQ_NOEXCEPT { _ptr = NULL; }
|
||||||
|
|
||||||
// Set value of atomic pointer in a non-threadsafe way
|
// Set value of atomic pointer in a non-threadsafe way
|
||||||
// Use this function only when you are sure that at most one
|
// Use this function only when you are sure that at most one
|
||||||
// thread is accessing the pointer at the moment.
|
// thread is accessing the pointer at the moment.
|
||||||
inline void set (T *ptr_) ZMQ_NOEXCEPT { _ptr = ptr_; }
|
void set (T *ptr_) ZMQ_NOEXCEPT { _ptr = ptr_; }
|
||||||
|
|
||||||
// Perform atomic 'exchange pointers' operation. Pointer is set
|
// Perform atomic 'exchange pointers' operation. Pointer is set
|
||||||
// to the 'val_' value. Old value is returned.
|
// to the 'val_' value. Old value is returned.
|
||||||
inline T *xchg (T *val_) ZMQ_NOEXCEPT
|
T *xchg (T *val_) ZMQ_NOEXCEPT
|
||||||
{
|
{
|
||||||
#if defined ZMQ_ATOMIC_PTR_CXX11
|
#if defined ZMQ_ATOMIC_PTR_CXX11
|
||||||
return _ptr.exchange (val_, std::memory_order_acq_rel);
|
return _ptr.exchange (val_, std::memory_order_acq_rel);
|
||||||
@@ -205,7 +205,7 @@ template <typename T> class atomic_ptr_t
|
|||||||
// The pointer is compared to 'cmp' argument and if they are
|
// The pointer is compared to 'cmp' argument and if they are
|
||||||
// equal, its value is set to 'val_'. Old value of the pointer
|
// equal, its value is set to 'val_'. Old value of the pointer
|
||||||
// is returned.
|
// is returned.
|
||||||
inline T *cas (T *cmp_, T *val_) ZMQ_NOEXCEPT
|
T *cas (T *cmp_, T *val_) ZMQ_NOEXCEPT
|
||||||
{
|
{
|
||||||
#if defined ZMQ_ATOMIC_PTR_CXX11
|
#if defined ZMQ_ATOMIC_PTR_CXX11
|
||||||
_ptr.compare_exchange_strong (cmp_, val_, std::memory_order_acq_rel);
|
_ptr.compare_exchange_strong (cmp_, val_, std::memory_order_acq_rel);
|
||||||
|
|||||||
@@ -45,20 +45,20 @@ class client_t ZMQ_FINAL : public socket_base_t
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
client_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
client_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||||
~client_t () ZMQ_FINAL;
|
~client_t ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Overrides of functions from socket_base_t.
|
// Overrides of functions from socket_base_t.
|
||||||
void xattach_pipe (zmq::pipe_t *pipe_,
|
void xattach_pipe (zmq::pipe_t *pipe_,
|
||||||
bool subscribe_to_all_,
|
bool subscribe_to_all_,
|
||||||
bool locally_initiated_) ZMQ_FINAL;
|
bool locally_initiated_);
|
||||||
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xsend (zmq::msg_t *msg_);
|
||||||
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xrecv (zmq::msg_t *msg_);
|
||||||
bool xhas_in () ZMQ_FINAL;
|
bool xhas_in ();
|
||||||
bool xhas_out () ZMQ_FINAL;
|
bool xhas_out ();
|
||||||
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xread_activated (zmq::pipe_t *pipe_);
|
||||||
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xwrite_activated (zmq::pipe_t *pipe_);
|
||||||
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xpipe_terminated (zmq::pipe_t *pipe_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Messages are fair-queued from inbound pipes. And load-balanced to
|
// Messages are fair-queued from inbound pipes. And load-balanced to
|
||||||
|
|||||||
@@ -101,9 +101,9 @@ namespace zmq
|
|||||||
class condition_variable_t
|
class condition_variable_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline condition_variable_t () ZMQ_DEFAULT;
|
condition_variable_t () ZMQ_DEFAULT;
|
||||||
|
|
||||||
inline int wait (mutex_t *mutex_, int timeout_)
|
int wait (mutex_t *mutex_, int timeout_)
|
||||||
{
|
{
|
||||||
// this assumes that the mutex mutex_ has been locked by the caller
|
// this assumes that the mutex mutex_ has been locked by the caller
|
||||||
int res = 0;
|
int res = 0;
|
||||||
@@ -119,7 +119,7 @@ class condition_variable_t
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void broadcast ()
|
void broadcast ()
|
||||||
{
|
{
|
||||||
// this assumes that the mutex associated with _cv has been locked by the caller
|
// this assumes that the mutex associated with _cv has been locked by the caller
|
||||||
_cv.notify_all ();
|
_cv.notify_all ();
|
||||||
|
|||||||
@@ -49,13 +49,13 @@ class curve_server_t ZMQ_FINAL : public zap_client_common_handshake_t,
|
|||||||
curve_server_t (session_base_t *session_,
|
curve_server_t (session_base_t *session_,
|
||||||
const std::string &peer_address_,
|
const std::string &peer_address_,
|
||||||
const options_t &options_);
|
const options_t &options_);
|
||||||
~curve_server_t () ZMQ_FINAL;
|
~curve_server_t ();
|
||||||
|
|
||||||
// mechanism implementation
|
// mechanism implementation
|
||||||
int next_handshake_command (msg_t *msg_) ZMQ_FINAL;
|
int next_handshake_command (msg_t *msg_);
|
||||||
int process_handshake_command (msg_t *msg_) ZMQ_FINAL;
|
int process_handshake_command (msg_t *msg_);
|
||||||
int encode (msg_t *msg_) ZMQ_FINAL;
|
int encode (msg_t *msg_);
|
||||||
int decode (msg_t *msg_) ZMQ_FINAL;
|
int decode (msg_t *msg_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Our secret key (s)
|
// Our secret key (s)
|
||||||
|
|||||||
@@ -58,22 +58,19 @@ template <typename T> class dbuffer_t;
|
|||||||
template <> class dbuffer_t<msg_t>
|
template <> class dbuffer_t<msg_t>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline dbuffer_t () :
|
dbuffer_t () : _back (&_storage[0]), _front (&_storage[1]), _has_msg (false)
|
||||||
_back (&_storage[0]),
|
|
||||||
_front (&_storage[1]),
|
|
||||||
_has_msg (false)
|
|
||||||
{
|
{
|
||||||
_back->init ();
|
_back->init ();
|
||||||
_front->init ();
|
_front->init ();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ~dbuffer_t ()
|
~dbuffer_t ()
|
||||||
{
|
{
|
||||||
_back->close ();
|
_back->close ();
|
||||||
_front->close ();
|
_front->close ();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void write (const msg_t &value_)
|
void write (const msg_t &value_)
|
||||||
{
|
{
|
||||||
msg_t &xvalue = const_cast<msg_t &> (value_);
|
msg_t &xvalue = const_cast<msg_t &> (value_);
|
||||||
|
|
||||||
@@ -90,7 +87,7 @@ template <> class dbuffer_t<msg_t>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool read (msg_t *value_)
|
bool read (msg_t *value_)
|
||||||
{
|
{
|
||||||
if (!value_)
|
if (!value_)
|
||||||
return false;
|
return false;
|
||||||
@@ -111,14 +108,14 @@ template <> class dbuffer_t<msg_t>
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool check_read ()
|
bool check_read ()
|
||||||
{
|
{
|
||||||
scoped_lock_t lock (_sync);
|
scoped_lock_t lock (_sync);
|
||||||
|
|
||||||
return _has_msg;
|
return _has_msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool probe (bool (*fn_) (const msg_t &))
|
bool probe (bool (*fn_) (const msg_t &))
|
||||||
{
|
{
|
||||||
scoped_lock_t lock (_sync);
|
scoped_lock_t lock (_sync);
|
||||||
return (*fn_) (*_front);
|
return (*fn_) (*_front);
|
||||||
|
|||||||
@@ -45,19 +45,19 @@ class dgram_t ZMQ_FINAL : public socket_base_t
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
dgram_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
dgram_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||||
~dgram_t () ZMQ_FINAL;
|
~dgram_t ();
|
||||||
|
|
||||||
// Overrides of functions from socket_base_t.
|
// Overrides of functions from socket_base_t.
|
||||||
void xattach_pipe (zmq::pipe_t *pipe_,
|
void xattach_pipe (zmq::pipe_t *pipe_,
|
||||||
bool subscribe_to_all_,
|
bool subscribe_to_all_,
|
||||||
bool locally_initiated_) ZMQ_FINAL;
|
bool locally_initiated_);
|
||||||
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xsend (zmq::msg_t *msg_);
|
||||||
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xrecv (zmq::msg_t *msg_);
|
||||||
bool xhas_in () ZMQ_FINAL;
|
bool xhas_in ();
|
||||||
bool xhas_out () ZMQ_FINAL;
|
bool xhas_out ();
|
||||||
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xread_activated (zmq::pipe_t *pipe_);
|
||||||
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xwrite_activated (zmq::pipe_t *pipe_);
|
||||||
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xpipe_terminated (zmq::pipe_t *pipe_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
zmq::pipe_t *_pipe;
|
zmq::pipe_t *_pipe;
|
||||||
|
|||||||
32
src/dish.hpp
32
src/dish.hpp
@@ -48,23 +48,23 @@ class dish_t ZMQ_FINAL : public socket_base_t
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
dish_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
dish_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||||
~dish_t () ZMQ_FINAL;
|
~dish_t ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Overrides of functions from socket_base_t.
|
// Overrides of functions from socket_base_t.
|
||||||
void xattach_pipe (zmq::pipe_t *pipe_,
|
void xattach_pipe (zmq::pipe_t *pipe_,
|
||||||
bool subscribe_to_all_,
|
bool subscribe_to_all_,
|
||||||
bool locally_initiated_) ZMQ_FINAL;
|
bool locally_initiated_);
|
||||||
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xsend (zmq::msg_t *msg_);
|
||||||
bool xhas_out () ZMQ_FINAL;
|
bool xhas_out ();
|
||||||
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xrecv (zmq::msg_t *msg_);
|
||||||
bool xhas_in () ZMQ_FINAL;
|
bool xhas_in ();
|
||||||
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xread_activated (zmq::pipe_t *pipe_);
|
||||||
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xwrite_activated (zmq::pipe_t *pipe_);
|
||||||
void xhiccuped (pipe_t *pipe_) ZMQ_FINAL;
|
void xhiccuped (pipe_t *pipe_);
|
||||||
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xpipe_terminated (zmq::pipe_t *pipe_);
|
||||||
int xjoin (const char *group_) ZMQ_FINAL;
|
int xjoin (const char *group_);
|
||||||
int xleave (const char *group_) ZMQ_FINAL;
|
int xleave (const char *group_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int xxrecv (zmq::msg_t *msg_);
|
int xxrecv (zmq::msg_t *msg_);
|
||||||
@@ -98,12 +98,12 @@ class dish_session_t ZMQ_FINAL : public session_base_t
|
|||||||
zmq::socket_base_t *socket_,
|
zmq::socket_base_t *socket_,
|
||||||
const options_t &options_,
|
const options_t &options_,
|
||||||
address_t *addr_);
|
address_t *addr_);
|
||||||
~dish_session_t () ZMQ_FINAL;
|
~dish_session_t ();
|
||||||
|
|
||||||
// Overrides of the functions from session_base_t.
|
// Overrides of the functions from session_base_t.
|
||||||
int push_msg (msg_t *msg_) ZMQ_FINAL;
|
int push_msg (msg_t *msg_);
|
||||||
int pull_msg (msg_t *msg_) ZMQ_FINAL;
|
int pull_msg (msg_t *msg_);
|
||||||
void reset () ZMQ_FINAL;
|
void reset ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum
|
enum
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace zmq
|
|||||||
template <typename T> class encoder_base_t : public i_encoder
|
template <typename T> class encoder_base_t : public i_encoder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline explicit encoder_base_t (size_t bufsize_) :
|
explicit encoder_base_t (size_t bufsize_) :
|
||||||
_write_pos (0),
|
_write_pos (0),
|
||||||
_to_write (0),
|
_to_write (0),
|
||||||
_next (NULL),
|
_next (NULL),
|
||||||
@@ -66,12 +66,12 @@ template <typename T> class encoder_base_t : public i_encoder
|
|||||||
alloc_assert (_buf);
|
alloc_assert (_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ~encoder_base_t () ZMQ_OVERRIDE { free (_buf); }
|
~encoder_base_t () ZMQ_OVERRIDE { free (_buf); }
|
||||||
|
|
||||||
// The function returns a batch of binary data. The data
|
// The function returns a batch of binary data. The data
|
||||||
// are filled to a supplied buffer. If no buffer is supplied (data_
|
// are filled to a supplied buffer. If no buffer is supplied (data_
|
||||||
// points to NULL) decoder object will provide buffer of its own.
|
// points to NULL) decoder object will provide buffer of its own.
|
||||||
inline size_t encode (unsigned char **data_, size_t size_) ZMQ_FINAL
|
size_t encode (unsigned char **data_, size_t size_) ZMQ_FINAL
|
||||||
{
|
{
|
||||||
unsigned char *buffer = !*data_ ? _buf : *data_;
|
unsigned char *buffer = !*data_ ? _buf : *data_;
|
||||||
const size_t buffersize = !*data_ ? _buf_size : size_;
|
const size_t buffersize = !*data_ ? _buf_size : size_;
|
||||||
@@ -139,10 +139,10 @@ template <typename T> class encoder_base_t : public i_encoder
|
|||||||
|
|
||||||
// This function should be called from derived class to write the data
|
// This function should be called from derived class to write the data
|
||||||
// to the buffer and schedule next state machine action.
|
// to the buffer and schedule next state machine action.
|
||||||
inline void next_step (void *write_pos_,
|
void next_step (void *write_pos_,
|
||||||
size_t to_write_,
|
size_t to_write_,
|
||||||
step_t next_,
|
step_t next_,
|
||||||
bool new_msg_flag_)
|
bool new_msg_flag_)
|
||||||
{
|
{
|
||||||
_write_pos = static_cast<unsigned char *> (write_pos_);
|
_write_pos = static_cast<unsigned char *> (write_pos_);
|
||||||
_to_write = to_write_;
|
_to_write = to_write_;
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class epoll_t ZMQ_FINAL : public worker_poller_base_t
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Main event loop.
|
// Main event loop.
|
||||||
void loop () ZMQ_FINAL;
|
void loop ();
|
||||||
|
|
||||||
// Main epoll file descriptor
|
// Main epoll file descriptor
|
||||||
epoll_fd_t _epoll_fd;
|
epoll_fd_t _epoll_fd;
|
||||||
|
|||||||
@@ -43,17 +43,17 @@ class gather_t ZMQ_FINAL : public socket_base_t
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
gather_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
gather_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||||
~gather_t () ZMQ_FINAL;
|
~gather_t ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Overrides of functions from socket_base_t.
|
// Overrides of functions from socket_base_t.
|
||||||
void xattach_pipe (zmq::pipe_t *pipe_,
|
void xattach_pipe (zmq::pipe_t *pipe_,
|
||||||
bool subscribe_to_all_,
|
bool subscribe_to_all_,
|
||||||
bool locally_initiated_) ZMQ_FINAL;
|
bool locally_initiated_);
|
||||||
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xrecv (zmq::msg_t *msg_);
|
||||||
bool xhas_in () ZMQ_FINAL;
|
bool xhas_in ();
|
||||||
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xread_activated (zmq::pipe_t *pipe_);
|
||||||
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xpipe_terminated (zmq::pipe_t *pipe_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Fair queueing object for inbound pipes.
|
// Fair queueing object for inbound pipes.
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class io_thread_t ZMQ_FINAL : public object_t, public i_poll_events
|
|||||||
|
|
||||||
// Clean-up. If the thread was started, it's necessary to call 'stop'
|
// Clean-up. If the thread was started, it's necessary to call 'stop'
|
||||||
// before invoking destructor. Otherwise the destructor would hang up.
|
// before invoking destructor. Otherwise the destructor would hang up.
|
||||||
~io_thread_t () ZMQ_FINAL;
|
~io_thread_t ();
|
||||||
|
|
||||||
// Launch the physical thread.
|
// Launch the physical thread.
|
||||||
void start ();
|
void start ();
|
||||||
@@ -62,15 +62,15 @@ class io_thread_t ZMQ_FINAL : public object_t, public i_poll_events
|
|||||||
mailbox_t *get_mailbox ();
|
mailbox_t *get_mailbox ();
|
||||||
|
|
||||||
// i_poll_events implementation.
|
// i_poll_events implementation.
|
||||||
void in_event () ZMQ_FINAL;
|
void in_event ();
|
||||||
void out_event () ZMQ_FINAL;
|
void out_event ();
|
||||||
void timer_event (int id_) ZMQ_FINAL;
|
void timer_event (int id_);
|
||||||
|
|
||||||
// Used by io_objects to retrieve the associated poller object.
|
// Used by io_objects to retrieve the associated poller object.
|
||||||
poller_t *get_poller () const;
|
poller_t *get_poller () const;
|
||||||
|
|
||||||
// Command handlers.
|
// Command handlers.
|
||||||
void process_stop () ZMQ_FINAL;
|
void process_stop ();
|
||||||
|
|
||||||
// Returns load experienced by the I/O thread.
|
// Returns load experienced by the I/O thread.
|
||||||
int get_load () const;
|
int get_load () const;
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ class ipc_connecter_t ZMQ_FINAL : public stream_connecter_base_t
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// Handlers for I/O events.
|
// Handlers for I/O events.
|
||||||
void out_event () ZMQ_FINAL;
|
void out_event ();
|
||||||
|
|
||||||
// Internal function to start the actual connection establishment.
|
// Internal function to start the actual connection establishment.
|
||||||
void start_connecting () ZMQ_FINAL;
|
void start_connecting ();
|
||||||
|
|
||||||
// Open IPC connecting socket. Returns -1 in case of error,
|
// Open IPC connecting socket. Returns -1 in case of error,
|
||||||
// 0 if connect was successful immediately. Returns -1 with
|
// 0 if connect was successful immediately. Returns -1 with
|
||||||
|
|||||||
@@ -50,12 +50,11 @@ class ipc_listener_t ZMQ_FINAL : public stream_listener_base_t
|
|||||||
int set_local_address (const char *addr_);
|
int set_local_address (const char *addr_);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string get_socket_name (fd_t fd_,
|
std::string get_socket_name (fd_t fd_, socket_end_t socket_end_) const;
|
||||||
socket_end_t socket_end_) const ZMQ_FINAL;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Handlers for I/O events.
|
// Handlers for I/O events.
|
||||||
void in_event () ZMQ_FINAL;
|
void in_event ();
|
||||||
|
|
||||||
// Filter new connections if the OS provides a mechanism to get
|
// Filter new connections if the OS provides a mechanism to get
|
||||||
// the credentials of the peer process. Called from accept().
|
// the credentials of the peer process. Called from accept().
|
||||||
@@ -63,7 +62,7 @@ class ipc_listener_t ZMQ_FINAL : public stream_listener_base_t
|
|||||||
bool filter (fd_t sock_);
|
bool filter (fd_t sock_);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int close () ZMQ_FINAL;
|
int close ();
|
||||||
|
|
||||||
// Accept the new connection. Returns the file descriptor of the
|
// Accept the new connection. Returns the file descriptor of the
|
||||||
// newly created connection. The function may return retired_fd
|
// newly created connection. The function may return retired_fd
|
||||||
|
|||||||
@@ -46,11 +46,11 @@ class mailbox_t ZMQ_FINAL : public i_mailbox
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
mailbox_t ();
|
mailbox_t ();
|
||||||
~mailbox_t () ZMQ_FINAL;
|
~mailbox_t ();
|
||||||
|
|
||||||
fd_t get_fd () const;
|
fd_t get_fd () const;
|
||||||
void send (const command_t &cmd_) ZMQ_FINAL;
|
void send (const command_t &cmd_);
|
||||||
int recv (command_t *cmd_, int timeout_) ZMQ_FINAL;
|
int recv (command_t *cmd_, int timeout_);
|
||||||
|
|
||||||
bool valid () const;
|
bool valid () const;
|
||||||
|
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ class mailbox_safe_t ZMQ_FINAL : public i_mailbox
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
mailbox_safe_t (mutex_t *sync_);
|
mailbox_safe_t (mutex_t *sync_);
|
||||||
~mailbox_safe_t () ZMQ_FINAL;
|
~mailbox_safe_t ();
|
||||||
|
|
||||||
void send (const command_t &cmd_) ZMQ_FINAL;
|
void send (const command_t &cmd_);
|
||||||
int recv (command_t *cmd_, int timeout_) ZMQ_FINAL;
|
int recv (command_t *cmd_, int timeout_);
|
||||||
|
|
||||||
// Add signaler to mailbox which will be called when a message is ready
|
// Add signaler to mailbox which will be called when a message is ready
|
||||||
void add_signaler (signaler_t *signaler_);
|
void add_signaler (signaler_t *signaler_);
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ class msg_t;
|
|||||||
class mechanism_base_t : public mechanism_t
|
class mechanism_base_t : public mechanism_t
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
mechanism_base_t (session_base_t *const session_,
|
mechanism_base_t (session_base_t *session_, const options_t &options_);
|
||||||
const options_t &options_);
|
|
||||||
|
|
||||||
session_base_t *const session;
|
session_base_t *const session;
|
||||||
|
|
||||||
|
|||||||
@@ -131,11 +131,12 @@ class msg_t
|
|||||||
|
|
||||||
// These are called on each message received by the session_base class,
|
// These are called on each message received by the session_base class,
|
||||||
// so get them inlined to avoid the overhead of 2 function calls per msg
|
// so get them inlined to avoid the overhead of 2 function calls per msg
|
||||||
inline bool is_subscribe () const
|
bool is_subscribe () const
|
||||||
{
|
{
|
||||||
return (_u.base.flags & CMD_TYPE_MASK) == subscribe;
|
return (_u.base.flags & CMD_TYPE_MASK) == subscribe;
|
||||||
}
|
}
|
||||||
inline bool is_cancel () const
|
|
||||||
|
bool is_cancel () const
|
||||||
{
|
{
|
||||||
return (_u.base.flags & CMD_TYPE_MASK) == cancel;
|
return (_u.base.flags & CMD_TYPE_MASK) == cancel;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,20 +44,17 @@ namespace zmq
|
|||||||
class mutex_t
|
class mutex_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline mutex_t () { InitializeCriticalSection (&_cs); }
|
mutex_t () { InitializeCriticalSection (&_cs); }
|
||||||
|
|
||||||
inline ~mutex_t () { DeleteCriticalSection (&_cs); }
|
~mutex_t () { DeleteCriticalSection (&_cs); }
|
||||||
|
|
||||||
inline void lock () { EnterCriticalSection (&_cs); }
|
void lock () { EnterCriticalSection (&_cs); }
|
||||||
|
|
||||||
inline bool try_lock ()
|
bool try_lock () { return (TryEnterCriticalSection (&_cs)) ? true : false; }
|
||||||
{
|
|
||||||
return (TryEnterCriticalSection (&_cs)) ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void unlock () { LeaveCriticalSection (&_cs); }
|
void unlock () { LeaveCriticalSection (&_cs); }
|
||||||
|
|
||||||
inline CRITICAL_SECTION *get_cs () { return &_cs; }
|
CRITICAL_SECTION *get_cs () { return &_cs; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CRITICAL_SECTION _cs;
|
CRITICAL_SECTION _cs;
|
||||||
|
|||||||
@@ -45,13 +45,13 @@ class null_mechanism_t ZMQ_FINAL : public zap_client_t
|
|||||||
null_mechanism_t (session_base_t *session_,
|
null_mechanism_t (session_base_t *session_,
|
||||||
const std::string &peer_address_,
|
const std::string &peer_address_,
|
||||||
const options_t &options_);
|
const options_t &options_);
|
||||||
~null_mechanism_t () ZMQ_FINAL;
|
~null_mechanism_t ();
|
||||||
|
|
||||||
// mechanism implementation
|
// mechanism implementation
|
||||||
int next_handshake_command (msg_t *msg_) ZMQ_FINAL;
|
int next_handshake_command (msg_t *msg_);
|
||||||
int process_handshake_command (msg_t *msg_) ZMQ_FINAL;
|
int process_handshake_command (msg_t *msg_);
|
||||||
int zap_msg_available () ZMQ_FINAL;
|
int zap_msg_available ();
|
||||||
status_t status () const ZMQ_FINAL;
|
status_t status () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _ready_command_sent;
|
bool _ready_command_sent;
|
||||||
|
|||||||
@@ -304,10 +304,10 @@ inline bool get_effective_conflate_option (const options_t &options)
|
|||||||
|| options.type == ZMQ_SUB);
|
|| options.type == ZMQ_SUB);
|
||||||
}
|
}
|
||||||
|
|
||||||
int do_getsockopt (void *const optval_,
|
int do_getsockopt (void *optval_,
|
||||||
size_t *const optvallen_,
|
size_t *optvallen_,
|
||||||
const void *value_,
|
const void *value_,
|
||||||
const size_t value_len_);
|
size_t value_len_);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
int do_getsockopt (void *const optval_, size_t *const optvallen_, T value_)
|
int do_getsockopt (void *const optval_, size_t *const optvallen_, T value_)
|
||||||
@@ -319,17 +319,17 @@ int do_getsockopt (void *const optval_, size_t *const optvallen_, T value_)
|
|||||||
return do_getsockopt (optval_, optvallen_, &value_, sizeof (T));
|
return do_getsockopt (optval_, optvallen_, &value_, sizeof (T));
|
||||||
}
|
}
|
||||||
|
|
||||||
int do_getsockopt (void *const optval_,
|
int do_getsockopt (void *optval_,
|
||||||
size_t *const optvallen_,
|
size_t *optvallen_,
|
||||||
const std::string &value_);
|
const std::string &value_);
|
||||||
|
|
||||||
int do_setsockopt_int_as_bool_strict (const void *const optval_,
|
int do_setsockopt_int_as_bool_strict (const void *optval_,
|
||||||
const size_t optvallen_,
|
size_t optvallen_,
|
||||||
bool *const out_value_);
|
bool *out_value_);
|
||||||
|
|
||||||
int do_setsockopt_int_as_bool_relaxed (const void *const optval_,
|
int do_setsockopt_int_as_bool_relaxed (const void *optval_,
|
||||||
const size_t optvallen_,
|
size_t optvallen_,
|
||||||
bool *const out_value_);
|
bool *out_value_);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
18
src/pair.hpp
18
src/pair.hpp
@@ -45,19 +45,19 @@ class pair_t ZMQ_FINAL : public socket_base_t
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
pair_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
pair_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||||
~pair_t () ZMQ_FINAL;
|
~pair_t ();
|
||||||
|
|
||||||
// Overrides of functions from socket_base_t.
|
// Overrides of functions from socket_base_t.
|
||||||
void xattach_pipe (zmq::pipe_t *pipe_,
|
void xattach_pipe (zmq::pipe_t *pipe_,
|
||||||
bool subscribe_to_all_,
|
bool subscribe_to_all_,
|
||||||
bool locally_initiated_) ZMQ_FINAL;
|
bool locally_initiated_);
|
||||||
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xsend (zmq::msg_t *msg_);
|
||||||
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xrecv (zmq::msg_t *msg_);
|
||||||
bool xhas_in () ZMQ_FINAL;
|
bool xhas_in ();
|
||||||
bool xhas_out () ZMQ_FINAL;
|
bool xhas_out ();
|
||||||
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xread_activated (zmq::pipe_t *pipe_);
|
||||||
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xwrite_activated (zmq::pipe_t *pipe_);
|
||||||
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xpipe_terminated (zmq::pipe_t *pipe_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
zmq::pipe_t *_pipe;
|
zmq::pipe_t *_pipe;
|
||||||
|
|||||||
@@ -40,13 +40,13 @@ class msg_t;
|
|||||||
class plain_client_t ZMQ_FINAL : public mechanism_base_t
|
class plain_client_t ZMQ_FINAL : public mechanism_base_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
plain_client_t (session_base_t *const session_, const options_t &options_);
|
plain_client_t (session_base_t *session_, const options_t &options_);
|
||||||
~plain_client_t () ZMQ_FINAL;
|
~plain_client_t ();
|
||||||
|
|
||||||
// mechanism implementation
|
// mechanism implementation
|
||||||
int next_handshake_command (msg_t *msg_) ZMQ_FINAL;
|
int next_handshake_command (msg_t *msg_);
|
||||||
int process_handshake_command (msg_t *msg_) ZMQ_FINAL;
|
int process_handshake_command (msg_t *msg_);
|
||||||
status_t status () const ZMQ_FINAL;
|
status_t status () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum state_t
|
enum state_t
|
||||||
|
|||||||
@@ -44,11 +44,11 @@ class plain_server_t ZMQ_FINAL : public zap_client_common_handshake_t
|
|||||||
plain_server_t (session_base_t *session_,
|
plain_server_t (session_base_t *session_,
|
||||||
const std::string &peer_address_,
|
const std::string &peer_address_,
|
||||||
const options_t &options_);
|
const options_t &options_);
|
||||||
~plain_server_t () ZMQ_FINAL;
|
~plain_server_t ();
|
||||||
|
|
||||||
// mechanism implementation
|
// mechanism implementation
|
||||||
int next_handshake_command (msg_t *msg_) ZMQ_FINAL;
|
int next_handshake_command (msg_t *msg_);
|
||||||
int process_handshake_command (msg_t *msg_) ZMQ_FINAL;
|
int process_handshake_command (msg_t *msg_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void produce_welcome (msg_t *msg_);
|
static void produce_welcome (msg_t *msg_);
|
||||||
|
|||||||
@@ -105,10 +105,8 @@ template <typename T, size_t S> class resizable_fast_vector_t
|
|||||||
#if defined ZMQ_POLL_BASED_ON_POLL
|
#if defined ZMQ_POLL_BASED_ON_POLL
|
||||||
typedef int timeout_t;
|
typedef int timeout_t;
|
||||||
|
|
||||||
timeout_t compute_timeout (const bool first_pass_,
|
timeout_t
|
||||||
const long timeout_,
|
compute_timeout (bool first_pass_, long timeout_, uint64_t now_, uint64_t end_);
|
||||||
const uint64_t now_,
|
|
||||||
const uint64_t end_);
|
|
||||||
|
|
||||||
#elif defined ZMQ_POLL_BASED_ON_SELECT
|
#elif defined ZMQ_POLL_BASED_ON_SELECT
|
||||||
inline size_t valid_pollset_bytes (const fd_set &pollset_)
|
inline size_t valid_pollset_bytes (const fd_set &pollset_)
|
||||||
|
|||||||
@@ -43,14 +43,14 @@ class pub_t ZMQ_FINAL : public xpub_t
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
pub_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
pub_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||||
~pub_t () ZMQ_FINAL;
|
~pub_t ();
|
||||||
|
|
||||||
// Implementations of virtual functions from socket_base_t.
|
// Implementations of virtual functions from socket_base_t.
|
||||||
void xattach_pipe (zmq::pipe_t *pipe_,
|
void xattach_pipe (zmq::pipe_t *pipe_,
|
||||||
bool subscribe_to_all_ = false,
|
bool subscribe_to_all_ = false,
|
||||||
bool locally_initiated_ = false) ZMQ_FINAL;
|
bool locally_initiated_ = false);
|
||||||
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xrecv (zmq::msg_t *msg_);
|
||||||
bool xhas_in () ZMQ_FINAL;
|
bool xhas_in ();
|
||||||
|
|
||||||
ZMQ_NON_COPYABLE_NOR_MOVABLE (pub_t)
|
ZMQ_NON_COPYABLE_NOR_MOVABLE (pub_t)
|
||||||
};
|
};
|
||||||
|
|||||||
12
src/pull.hpp
12
src/pull.hpp
@@ -45,17 +45,17 @@ class pull_t ZMQ_FINAL : public socket_base_t
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
pull_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
pull_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||||
~pull_t () ZMQ_FINAL;
|
~pull_t ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Overrides of functions from socket_base_t.
|
// Overrides of functions from socket_base_t.
|
||||||
void xattach_pipe (zmq::pipe_t *pipe_,
|
void xattach_pipe (zmq::pipe_t *pipe_,
|
||||||
bool subscribe_to_all_,
|
bool subscribe_to_all_,
|
||||||
bool locally_initiated_) ZMQ_FINAL;
|
bool locally_initiated_);
|
||||||
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xrecv (zmq::msg_t *msg_);
|
||||||
bool xhas_in () ZMQ_FINAL;
|
bool xhas_in ();
|
||||||
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xread_activated (zmq::pipe_t *pipe_);
|
||||||
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xpipe_terminated (zmq::pipe_t *pipe_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Fair queueing object for inbound pipes.
|
// Fair queueing object for inbound pipes.
|
||||||
|
|||||||
12
src/push.hpp
12
src/push.hpp
@@ -45,17 +45,17 @@ class push_t ZMQ_FINAL : public socket_base_t
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
push_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
push_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||||
~push_t () ZMQ_FINAL;
|
~push_t ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Overrides of functions from socket_base_t.
|
// Overrides of functions from socket_base_t.
|
||||||
void xattach_pipe (zmq::pipe_t *pipe_,
|
void xattach_pipe (zmq::pipe_t *pipe_,
|
||||||
bool subscribe_to_all_,
|
bool subscribe_to_all_,
|
||||||
bool locally_initiated_) ZMQ_FINAL;
|
bool locally_initiated_);
|
||||||
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xsend (zmq::msg_t *msg_);
|
||||||
bool xhas_out () ZMQ_FINAL;
|
bool xhas_out ();
|
||||||
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xwrite_activated (zmq::pipe_t *pipe_);
|
||||||
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xpipe_terminated (zmq::pipe_t *pipe_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Load balancer managing the outbound pipes.
|
// Load balancer managing the outbound pipes.
|
||||||
|
|||||||
@@ -49,21 +49,20 @@ class radio_t ZMQ_FINAL : public socket_base_t
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
radio_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
radio_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||||
~radio_t () ZMQ_FINAL;
|
~radio_t ();
|
||||||
|
|
||||||
// Implementations of virtual functions from socket_base_t.
|
// Implementations of virtual functions from socket_base_t.
|
||||||
void xattach_pipe (zmq::pipe_t *pipe_,
|
void xattach_pipe (zmq::pipe_t *pipe_,
|
||||||
bool subscribe_to_all_ = false,
|
bool subscribe_to_all_ = false,
|
||||||
bool locally_initiated_ = false) ZMQ_FINAL;
|
bool locally_initiated_ = false);
|
||||||
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xsend (zmq::msg_t *msg_);
|
||||||
bool xhas_out () ZMQ_FINAL;
|
bool xhas_out ();
|
||||||
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xrecv (zmq::msg_t *msg_);
|
||||||
bool xhas_in () ZMQ_FINAL;
|
bool xhas_in ();
|
||||||
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xread_activated (zmq::pipe_t *pipe_);
|
||||||
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xwrite_activated (zmq::pipe_t *pipe_);
|
||||||
int
|
int xsetsockopt (int option_, const void *optval_, size_t optvallen_);
|
||||||
xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_FINAL;
|
void xpipe_terminated (zmq::pipe_t *pipe_);
|
||||||
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// List of all subscriptions mapped to corresponding pipes.
|
// List of all subscriptions mapped to corresponding pipes.
|
||||||
@@ -91,12 +90,12 @@ class radio_session_t ZMQ_FINAL : public session_base_t
|
|||||||
zmq::socket_base_t *socket_,
|
zmq::socket_base_t *socket_,
|
||||||
const options_t &options_,
|
const options_t &options_,
|
||||||
address_t *addr_);
|
address_t *addr_);
|
||||||
~radio_session_t () ZMQ_FINAL;
|
~radio_session_t ();
|
||||||
|
|
||||||
// Overrides of the functions from session_base_t.
|
// Overrides of the functions from session_base_t.
|
||||||
int push_msg (msg_t *msg_) ZMQ_FINAL;
|
int push_msg (msg_t *msg_);
|
||||||
int pull_msg (msg_t *msg_) ZMQ_FINAL;
|
int pull_msg (msg_t *msg_);
|
||||||
void reset () ZMQ_FINAL;
|
void reset ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum
|
enum
|
||||||
|
|||||||
@@ -43,19 +43,17 @@ class raw_decoder_t ZMQ_FINAL : public i_decoder
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
raw_decoder_t (size_t bufsize_);
|
raw_decoder_t (size_t bufsize_);
|
||||||
~raw_decoder_t () ZMQ_FINAL;
|
~raw_decoder_t ();
|
||||||
|
|
||||||
// i_decoder interface.
|
// i_decoder interface.
|
||||||
|
|
||||||
void get_buffer (unsigned char **data_, size_t *size_) ZMQ_FINAL;
|
void get_buffer (unsigned char **data_, size_t *size_);
|
||||||
|
|
||||||
int decode (const unsigned char *data_,
|
int decode (const unsigned char *data_, size_t size_, size_t &bytes_used_);
|
||||||
size_t size_,
|
|
||||||
size_t &bytes_used_) ZMQ_FINAL;
|
|
||||||
|
|
||||||
msg_t *msg () ZMQ_FINAL { return &_in_progress; }
|
msg_t *msg () { return &_in_progress; }
|
||||||
|
|
||||||
void resize_buffer (size_t) ZMQ_FINAL {}
|
void resize_buffer (size_t) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
msg_t _in_progress;
|
msg_t _in_progress;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class raw_encoder_t ZMQ_FINAL : public encoder_base_t<raw_encoder_t>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
raw_encoder_t (size_t bufsize_);
|
raw_encoder_t (size_t bufsize_);
|
||||||
~raw_encoder_t () ZMQ_FINAL;
|
~raw_encoder_t ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void raw_message_ready ();
|
void raw_message_ready ();
|
||||||
|
|||||||
@@ -60,12 +60,12 @@ class raw_engine_t ZMQ_FINAL : public stream_engine_base_t
|
|||||||
raw_engine_t (fd_t fd_,
|
raw_engine_t (fd_t fd_,
|
||||||
const options_t &options_,
|
const options_t &options_,
|
||||||
const endpoint_uri_pair_t &endpoint_uri_pair_);
|
const endpoint_uri_pair_t &endpoint_uri_pair_);
|
||||||
~raw_engine_t () ZMQ_FINAL;
|
~raw_engine_t ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void error (error_reason_t reason_) ZMQ_FINAL;
|
void error (error_reason_t reason_);
|
||||||
void plug_internal () ZMQ_FINAL;
|
void plug_internal ();
|
||||||
bool handshake () ZMQ_FINAL;
|
bool handshake ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int push_raw_msg_to_session (msg_t *msg_);
|
int push_raw_msg_to_session (msg_t *msg_);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class reaper_t ZMQ_FINAL : public object_t, public i_poll_events
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
reaper_t (zmq::ctx_t *ctx_, uint32_t tid_);
|
reaper_t (zmq::ctx_t *ctx_, uint32_t tid_);
|
||||||
~reaper_t () ZMQ_FINAL;
|
~reaper_t ();
|
||||||
|
|
||||||
mailbox_t *get_mailbox ();
|
mailbox_t *get_mailbox ();
|
||||||
|
|
||||||
@@ -52,15 +52,15 @@ class reaper_t ZMQ_FINAL : public object_t, public i_poll_events
|
|||||||
void stop ();
|
void stop ();
|
||||||
|
|
||||||
// i_poll_events implementation.
|
// i_poll_events implementation.
|
||||||
void in_event () ZMQ_FINAL;
|
void in_event ();
|
||||||
void out_event () ZMQ_FINAL;
|
void out_event ();
|
||||||
void timer_event (int id_) ZMQ_FINAL;
|
void timer_event (int id_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Command handlers.
|
// Command handlers.
|
||||||
void process_stop () ZMQ_FINAL;
|
void process_stop ();
|
||||||
void process_reap (zmq::socket_base_t *socket_) ZMQ_FINAL;
|
void process_reap (zmq::socket_base_t *socket_);
|
||||||
void process_reaped () ZMQ_FINAL;
|
void process_reaped ();
|
||||||
|
|
||||||
// Reaper thread accesses incoming commands via this mailbox.
|
// Reaper thread accesses incoming commands via this mailbox.
|
||||||
mailbox_t _mailbox;
|
mailbox_t _mailbox;
|
||||||
|
|||||||
10
src/rep.hpp
10
src/rep.hpp
@@ -43,13 +43,13 @@ class rep_t ZMQ_FINAL : public router_t
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
rep_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
rep_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||||
~rep_t () ZMQ_FINAL;
|
~rep_t ();
|
||||||
|
|
||||||
// Overrides of functions from socket_base_t.
|
// Overrides of functions from socket_base_t.
|
||||||
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xsend (zmq::msg_t *msg_);
|
||||||
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xrecv (zmq::msg_t *msg_);
|
||||||
bool xhas_in () ZMQ_FINAL;
|
bool xhas_in ();
|
||||||
bool xhas_out () ZMQ_FINAL;
|
bool xhas_out ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// If true, we are in process of sending the reply. If false we are
|
// If true, we are in process of sending the reply. If false we are
|
||||||
|
|||||||
21
src/req.hpp
21
src/req.hpp
@@ -44,16 +44,15 @@ class req_t ZMQ_FINAL : public dealer_t
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
req_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
req_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||||
~req_t () ZMQ_FINAL;
|
~req_t ();
|
||||||
|
|
||||||
// Overrides of functions from socket_base_t.
|
// Overrides of functions from socket_base_t.
|
||||||
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xsend (zmq::msg_t *msg_);
|
||||||
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xrecv (zmq::msg_t *msg_);
|
||||||
bool xhas_in () ZMQ_FINAL;
|
bool xhas_in ();
|
||||||
bool xhas_out () ZMQ_FINAL;
|
bool xhas_out ();
|
||||||
int
|
int xsetsockopt (int option_, const void *optval_, size_t optvallen_);
|
||||||
xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_FINAL;
|
void xpipe_terminated (zmq::pipe_t *pipe_);
|
||||||
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Receive only from the pipe the request was sent to, discarding
|
// Receive only from the pipe the request was sent to, discarding
|
||||||
@@ -95,11 +94,11 @@ class req_session_t ZMQ_FINAL : public session_base_t
|
|||||||
zmq::socket_base_t *socket_,
|
zmq::socket_base_t *socket_,
|
||||||
const options_t &options_,
|
const options_t &options_,
|
||||||
address_t *addr_);
|
address_t *addr_);
|
||||||
~req_session_t () ZMQ_FINAL;
|
~req_session_t ();
|
||||||
|
|
||||||
// Overrides of the functions from session_base_t.
|
// Overrides of the functions from session_base_t.
|
||||||
int push_msg (msg_t *msg_) ZMQ_FINAL;
|
int push_msg (msg_t *msg_);
|
||||||
void reset () ZMQ_FINAL;
|
void reset ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum
|
enum
|
||||||
|
|||||||
@@ -45,17 +45,17 @@ class scatter_t ZMQ_FINAL : public socket_base_t
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
scatter_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
scatter_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||||
~scatter_t () ZMQ_FINAL;
|
~scatter_t ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Overrides of functions from socket_base_t.
|
// Overrides of functions from socket_base_t.
|
||||||
void xattach_pipe (zmq::pipe_t *pipe_,
|
void xattach_pipe (zmq::pipe_t *pipe_,
|
||||||
bool subscribe_to_all_,
|
bool subscribe_to_all_,
|
||||||
bool locally_initiated_) ZMQ_FINAL;
|
bool locally_initiated_);
|
||||||
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xsend (zmq::msg_t *msg_);
|
||||||
bool xhas_out () ZMQ_FINAL;
|
bool xhas_out ();
|
||||||
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xwrite_activated (zmq::pipe_t *pipe_);
|
||||||
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xpipe_terminated (zmq::pipe_t *pipe_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Load balancer managing the outbound pipes.
|
// Load balancer managing the outbound pipes.
|
||||||
|
|||||||
@@ -49,19 +49,19 @@ class server_t ZMQ_FINAL : public socket_base_t
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
server_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
server_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||||
~server_t () ZMQ_FINAL;
|
~server_t ();
|
||||||
|
|
||||||
// Overrides of functions from socket_base_t.
|
// Overrides of functions from socket_base_t.
|
||||||
void xattach_pipe (zmq::pipe_t *pipe_,
|
void xattach_pipe (zmq::pipe_t *pipe_,
|
||||||
bool subscribe_to_all_,
|
bool subscribe_to_all_,
|
||||||
bool locally_initiated_) ZMQ_FINAL;
|
bool locally_initiated_);
|
||||||
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xsend (zmq::msg_t *msg_);
|
||||||
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xrecv (zmq::msg_t *msg_);
|
||||||
bool xhas_in () ZMQ_FINAL;
|
bool xhas_in ();
|
||||||
bool xhas_out () ZMQ_FINAL;
|
bool xhas_out ();
|
||||||
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xread_activated (zmq::pipe_t *pipe_);
|
||||||
void xwrite_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xwrite_activated (zmq::pipe_t *pipe_);
|
||||||
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xpipe_terminated (zmq::pipe_t *pipe_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Fair queueing object for inbound pipes.
|
// Fair queueing object for inbound pipes.
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class socket_poller_t
|
|||||||
|
|
||||||
int wait (event_t *events_, int n_events_, long timeout_);
|
int wait (event_t *events_, int n_events_, long timeout_);
|
||||||
|
|
||||||
inline int size () const { return static_cast<int> (_items.size ()); };
|
int size () const { return static_cast<int> (_items.size ()); };
|
||||||
|
|
||||||
// Return false if object is not a socket.
|
// Return false if object is not a socket.
|
||||||
bool check_tag () const;
|
bool check_tag () const;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class socks_connecter_t ZMQ_FINAL : public stream_connecter_base_t
|
|||||||
address_t *addr_,
|
address_t *addr_,
|
||||||
address_t *proxy_addr_,
|
address_t *proxy_addr_,
|
||||||
bool delayed_start_);
|
bool delayed_start_);
|
||||||
~socks_connecter_t () ZMQ_FINAL;
|
~socks_connecter_t ();
|
||||||
|
|
||||||
void set_auth_method_basic (const std::string &username,
|
void set_auth_method_basic (const std::string &username,
|
||||||
const std::string &password);
|
const std::string &password);
|
||||||
@@ -82,11 +82,11 @@ class socks_connecter_t ZMQ_FINAL : public stream_connecter_base_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Handlers for I/O events.
|
// Handlers for I/O events.
|
||||||
void in_event () ZMQ_FINAL;
|
void in_event ();
|
||||||
void out_event () ZMQ_FINAL;
|
void out_event ();
|
||||||
|
|
||||||
// Internal function to start the actual connection establishment.
|
// Internal function to start the actual connection establishment.
|
||||||
void start_connecting () ZMQ_FINAL;
|
void start_connecting ();
|
||||||
|
|
||||||
static int process_server_response (const socks_choice_t &response_);
|
static int process_server_response (const socks_choice_t &response_);
|
||||||
static int process_server_response (const socks_response_t &response_);
|
static int process_server_response (const socks_response_t &response_);
|
||||||
|
|||||||
@@ -43,20 +43,19 @@ class stream_t ZMQ_FINAL : public routing_socket_base_t
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
stream_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
stream_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||||
~stream_t () ZMQ_FINAL;
|
~stream_t ();
|
||||||
|
|
||||||
// Overrides of functions from socket_base_t.
|
// Overrides of functions from socket_base_t.
|
||||||
void xattach_pipe (zmq::pipe_t *pipe_,
|
void xattach_pipe (zmq::pipe_t *pipe_,
|
||||||
bool subscribe_to_all_,
|
bool subscribe_to_all_,
|
||||||
bool locally_initiated_) ZMQ_FINAL;
|
bool locally_initiated_);
|
||||||
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xsend (zmq::msg_t *msg_);
|
||||||
int xrecv (zmq::msg_t *msg_) ZMQ_FINAL;
|
int xrecv (zmq::msg_t *msg_);
|
||||||
bool xhas_in () ZMQ_FINAL;
|
bool xhas_in ();
|
||||||
bool xhas_out () ZMQ_FINAL;
|
bool xhas_out ();
|
||||||
void xread_activated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xread_activated (zmq::pipe_t *pipe_);
|
||||||
void xpipe_terminated (zmq::pipe_t *pipe_) ZMQ_FINAL;
|
void xpipe_terminated (zmq::pipe_t *pipe_);
|
||||||
int
|
int xsetsockopt (int option_, const void *optval_, size_t optvallen_);
|
||||||
xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_FINAL;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Generate peer's id and update lookup map
|
// Generate peer's id and update lookup map
|
||||||
|
|||||||
@@ -43,13 +43,12 @@ class sub_t ZMQ_FINAL : public xsub_t
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
sub_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
sub_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||||
~sub_t () ZMQ_FINAL;
|
~sub_t ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int
|
int xsetsockopt (int option_, const void *optval_, size_t optvallen_);
|
||||||
xsetsockopt (int option_, const void *optval_, size_t optvallen_) ZMQ_FINAL;
|
int xsend (zmq::msg_t *msg_);
|
||||||
int xsend (zmq::msg_t *msg_) ZMQ_FINAL;
|
bool xhas_out ();
|
||||||
bool xhas_out () ZMQ_FINAL;
|
|
||||||
|
|
||||||
ZMQ_NON_COPYABLE_NOR_MOVABLE (sub_t)
|
ZMQ_NON_COPYABLE_NOR_MOVABLE (sub_t)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ int tcp_write (fd_t s_, const void *data_, size_t size_);
|
|||||||
// Zero indicates the peer has closed the connection.
|
// Zero indicates the peer has closed the connection.
|
||||||
int tcp_read (fd_t s_, void *data_, size_t size_);
|
int tcp_read (fd_t s_, void *data_, size_t size_);
|
||||||
|
|
||||||
void tcp_tune_loopback_fast_path (const fd_t socket_);
|
void tcp_tune_loopback_fast_path (fd_t socket_);
|
||||||
|
|
||||||
// Resolves the given address_ string, opens a socket and sets socket options
|
// Resolves the given address_ string, opens a socket and sets socket options
|
||||||
// according to the passed options_. On success, returns the socket
|
// according to the passed options_. On success, returns the socket
|
||||||
|
|||||||
@@ -87,8 +87,7 @@ class tcp_address_mask_t
|
|||||||
|
|
||||||
int mask () const;
|
int mask () const;
|
||||||
|
|
||||||
bool match_address (const struct sockaddr *ss_,
|
bool match_address (const struct sockaddr *ss_, socklen_t ss_len_) const;
|
||||||
const socklen_t ss_len_) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ip_addr_t _network_address;
|
ip_addr_t _network_address;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class tcp_connecter_t ZMQ_FINAL : public stream_connecter_base_t
|
|||||||
const options_t &options_,
|
const options_t &options_,
|
||||||
address_t *addr_,
|
address_t *addr_,
|
||||||
bool delayed_start_);
|
bool delayed_start_);
|
||||||
~tcp_connecter_t () ZMQ_FINAL;
|
~tcp_connecter_t ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// ID of the timer used to check the connect timeout, must be different from stream_connecter_base_t::reconnect_timer_id.
|
// 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 ZMQ_FINAL : public stream_connecter_base_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Handlers for incoming commands.
|
// Handlers for incoming commands.
|
||||||
void process_term (int linger_) ZMQ_FINAL;
|
void process_term (int linger_);
|
||||||
|
|
||||||
// Handlers for I/O events.
|
// Handlers for I/O events.
|
||||||
void out_event () ZMQ_FINAL;
|
void out_event ();
|
||||||
void timer_event (int id_) ZMQ_FINAL;
|
void timer_event (int id_);
|
||||||
|
|
||||||
// Internal function to start the actual connection establishment.
|
// Internal function to start the actual connection establishment.
|
||||||
void start_connecting () ZMQ_FINAL;
|
void start_connecting ();
|
||||||
|
|
||||||
// Internal function to add a connect timer
|
// Internal function to add a connect timer
|
||||||
void add_connect_timer ();
|
void add_connect_timer ();
|
||||||
|
|||||||
@@ -47,12 +47,11 @@ class tcp_listener_t ZMQ_FINAL : public stream_listener_base_t
|
|||||||
int set_local_address (const char *addr_);
|
int set_local_address (const char *addr_);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string get_socket_name (fd_t fd_,
|
std::string get_socket_name (fd_t fd_, socket_end_t socket_end_) const;
|
||||||
socket_end_t socket_end_) const ZMQ_FINAL;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Handlers for I/O events.
|
// Handlers for I/O events.
|
||||||
void in_event () ZMQ_FINAL;
|
void in_event ();
|
||||||
|
|
||||||
// Accept the new connection. Returns the file descriptor of the
|
// Accept the new connection. Returns the file descriptor of the
|
||||||
// newly created connection. The function may return retired_fd
|
// newly created connection. The function may return retired_fd
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ typedef void(thread_fn) (void *);
|
|||||||
class thread_t
|
class thread_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline thread_t () :
|
thread_t () :
|
||||||
_tfn (NULL),
|
_tfn (NULL),
|
||||||
_arg (NULL),
|
_arg (NULL),
|
||||||
_started (false),
|
_started (false),
|
||||||
|
|||||||
@@ -18,33 +18,32 @@ class udp_engine_t ZMQ_FINAL : public io_object_t, public i_engine
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
udp_engine_t (const options_t &options_);
|
udp_engine_t (const options_t &options_);
|
||||||
~udp_engine_t () ZMQ_FINAL;
|
~udp_engine_t ();
|
||||||
|
|
||||||
int init (address_t *address_, bool send_, bool recv_);
|
int init (address_t *address_, bool send_, bool recv_);
|
||||||
|
|
||||||
// i_engine interface implementation.
|
// i_engine interface implementation.
|
||||||
// Plug the engine to the session.
|
// Plug the engine to the session.
|
||||||
void plug (zmq::io_thread_t *io_thread_,
|
void plug (zmq::io_thread_t *io_thread_, class session_base_t *session_);
|
||||||
class session_base_t *session_) ZMQ_FINAL;
|
|
||||||
|
|
||||||
// Terminate and deallocate the engine. Note that 'detached'
|
// Terminate and deallocate the engine. Note that 'detached'
|
||||||
// events are not fired on termination.
|
// events are not fired on termination.
|
||||||
void terminate () ZMQ_FINAL;
|
void terminate ();
|
||||||
|
|
||||||
// This method is called by the session to signalise that more
|
// This method is called by the session to signalise that more
|
||||||
// messages can be written to the pipe.
|
// messages can be written to the pipe.
|
||||||
bool restart_input () ZMQ_FINAL;
|
bool restart_input ();
|
||||||
|
|
||||||
// This method is called by the session to signalise that there
|
// This method is called by the session to signalise that there
|
||||||
// are messages to send available.
|
// are messages to send available.
|
||||||
void restart_output () ZMQ_FINAL;
|
void restart_output ();
|
||||||
|
|
||||||
void zap_msg_available () ZMQ_FINAL{};
|
void zap_msg_available (){};
|
||||||
|
|
||||||
void in_event () ZMQ_FINAL;
|
void in_event ();
|
||||||
void out_event () ZMQ_FINAL;
|
void out_event ();
|
||||||
|
|
||||||
const endpoint_uri_pair_t &get_endpoint () const ZMQ_FINAL;
|
const endpoint_uri_pair_t &get_endpoint () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int resolve_raw_address (const char *name_, size_t length_);
|
int resolve_raw_address (const char *name_, size_t length_);
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ class v1_decoder_t ZMQ_FINAL : public decoder_base_t<v1_decoder_t>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
v1_decoder_t (size_t bufsize_, int64_t maxmsgsize_);
|
v1_decoder_t (size_t bufsize_, int64_t maxmsgsize_);
|
||||||
~v1_decoder_t () ZMQ_FINAL;
|
~v1_decoder_t ();
|
||||||
|
|
||||||
msg_t *msg () ZMQ_FINAL { return &_in_progress; }
|
msg_t *msg () { return &_in_progress; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int one_byte_size_ready (unsigned char const *);
|
int one_byte_size_ready (unsigned char const *);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class v1_encoder_t ZMQ_FINAL : public encoder_base_t<v1_encoder_t>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
v1_encoder_t (size_t bufsize_);
|
v1_encoder_t (size_t bufsize_);
|
||||||
~v1_encoder_t () ZMQ_FINAL;
|
~v1_encoder_t ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void size_ready ();
|
void size_ready ();
|
||||||
|
|||||||
@@ -43,10 +43,10 @@ class v2_decoder_t ZMQ_FINAL
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
v2_decoder_t (size_t bufsize_, int64_t maxmsgsize_, bool zero_copy_);
|
v2_decoder_t (size_t bufsize_, int64_t maxmsgsize_, bool zero_copy_);
|
||||||
~v2_decoder_t () ZMQ_FINAL;
|
~v2_decoder_t ();
|
||||||
|
|
||||||
// i_decoder interface.
|
// i_decoder interface.
|
||||||
msg_t *msg () ZMQ_FINAL { return &_in_progress; }
|
msg_t *msg () { return &_in_progress; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int flags_ready (unsigned char const *);
|
int flags_ready (unsigned char const *);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class v2_encoder_t ZMQ_FINAL : public encoder_base_t<v2_encoder_t>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
v2_encoder_t (size_t bufsize_);
|
v2_encoder_t (size_t bufsize_);
|
||||||
~v2_encoder_t () ZMQ_FINAL;
|
~v2_encoder_t ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void size_ready ();
|
void size_ready ();
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ class ws_connecter_t ZMQ_FINAL : public stream_connecter_base_t
|
|||||||
bool delayed_start_,
|
bool delayed_start_,
|
||||||
bool wss_,
|
bool wss_,
|
||||||
const std::string &tls_hostname_);
|
const std::string &tls_hostname_);
|
||||||
~ws_connecter_t () ZMQ_FINAL;
|
~ws_connecter_t ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void create_engine (fd_t fd, const std::string &local_address_) ZMQ_FINAL;
|
void create_engine (fd_t fd, const std::string &local_address_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// ID of the timer used to check the connect timeout, must be different from stream_connecter_base_t::reconnect_timer_id.
|
// 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 ZMQ_FINAL : public stream_connecter_base_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Handlers for incoming commands.
|
// Handlers for incoming commands.
|
||||||
void process_term (int linger_) ZMQ_FINAL;
|
void process_term (int linger_);
|
||||||
|
|
||||||
// Handlers for I/O events.
|
// Handlers for I/O events.
|
||||||
void out_event () ZMQ_FINAL;
|
void out_event ();
|
||||||
void timer_event (int id_) ZMQ_FINAL;
|
void timer_event (int id_);
|
||||||
|
|
||||||
// Internal function to start the actual connection establishment.
|
// Internal function to start the actual connection establishment.
|
||||||
void start_connecting () ZMQ_FINAL;
|
void start_connecting ();
|
||||||
|
|
||||||
// Internal function to add a connect timer
|
// Internal function to add a connect timer
|
||||||
void add_connect_timer ();
|
void add_connect_timer ();
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ class ws_decoder_t ZMQ_FINAL
|
|||||||
int64_t maxmsgsize_,
|
int64_t maxmsgsize_,
|
||||||
bool zero_copy_,
|
bool zero_copy_,
|
||||||
bool must_mask_);
|
bool must_mask_);
|
||||||
~ws_decoder_t () ZMQ_FINAL;
|
~ws_decoder_t ();
|
||||||
|
|
||||||
// i_decoder interface.
|
// i_decoder interface.
|
||||||
msg_t *msg () ZMQ_FINAL { return &_in_progress; }
|
msg_t *msg () { return &_in_progress; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int opcode_ready (unsigned char const *);
|
int opcode_ready (unsigned char const *);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class ws_encoder_t ZMQ_FINAL : public encoder_base_t<ws_encoder_t>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ws_encoder_t (size_t bufsize_, bool must_mask_);
|
ws_encoder_t (size_t bufsize_, bool must_mask_);
|
||||||
~ws_encoder_t () ZMQ_FINAL;
|
~ws_encoder_t ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void size_ready ();
|
void size_ready ();
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ class ws_engine_t ZMQ_FINAL : public stream_engine_base_t
|
|||||||
const endpoint_uri_pair_t &endpoint_uri_pair_,
|
const endpoint_uri_pair_t &endpoint_uri_pair_,
|
||||||
const ws_address_t &address_,
|
const ws_address_t &address_,
|
||||||
bool client_);
|
bool client_);
|
||||||
~ws_engine_t () ZMQ_FINAL;
|
~ws_engine_t ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int decode_and_push (msg_t *msg_);
|
int decode_and_push (msg_t *msg_);
|
||||||
|
|||||||
@@ -48,19 +48,18 @@ class ws_listener_t ZMQ_FINAL : public stream_listener_base_t
|
|||||||
const options_t &options_,
|
const options_t &options_,
|
||||||
bool wss_);
|
bool wss_);
|
||||||
|
|
||||||
~ws_listener_t () ZMQ_FINAL;
|
~ws_listener_t ();
|
||||||
|
|
||||||
// Set address to listen on.
|
// Set address to listen on.
|
||||||
int set_local_address (const char *addr_);
|
int set_local_address (const char *addr_);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string get_socket_name (fd_t fd_,
|
std::string get_socket_name (fd_t fd_, socket_end_t socket_end_) const;
|
||||||
socket_end_t socket_end_) const ZMQ_FINAL;
|
void create_engine (fd_t fd);
|
||||||
void create_engine (fd_t fd) ZMQ_FINAL;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Handlers for I/O events.
|
// Handlers for I/O events.
|
||||||
void in_event () ZMQ_FINAL;
|
void in_event ();
|
||||||
|
|
||||||
// Accept the new connection. Returns the file descriptor of the
|
// Accept the new connection. Returns the file descriptor of the
|
||||||
// newly created connection. The function may return retired_fd
|
// newly created connection. The function may return retired_fd
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ template <typename T, int N> class ypipe_t ZMQ_FINAL : public ypipe_base_t<T>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Initialises the pipe.
|
// Initialises the pipe.
|
||||||
inline ypipe_t ()
|
ypipe_t ()
|
||||||
{
|
{
|
||||||
// Insert terminator element into the queue.
|
// Insert terminator element into the queue.
|
||||||
_queue.push ();
|
_queue.push ();
|
||||||
@@ -71,7 +71,7 @@ template <typename T, int N> class ypipe_t ZMQ_FINAL : public ypipe_base_t<T>
|
|||||||
// set to true the item is assumed to be continued by items
|
// set to true the item is assumed to be continued by items
|
||||||
// subsequently written to the pipe. Incomplete items are never
|
// subsequently written to the pipe. Incomplete items are never
|
||||||
// flushed down the stream.
|
// flushed down the stream.
|
||||||
inline void write (const T &value_, bool incomplete_) ZMQ_FINAL
|
void write (const T &value_, bool incomplete_)
|
||||||
{
|
{
|
||||||
// Place the value to the queue, add new terminator element.
|
// Place the value to the queue, add new terminator element.
|
||||||
_queue.back () = value_;
|
_queue.back () = value_;
|
||||||
@@ -88,7 +88,7 @@ template <typename T, int N> class ypipe_t ZMQ_FINAL : public ypipe_base_t<T>
|
|||||||
|
|
||||||
// Pop an incomplete item from the pipe. Returns true if such
|
// Pop an incomplete item from the pipe. Returns true if such
|
||||||
// item exists, false otherwise.
|
// item exists, false otherwise.
|
||||||
inline bool unwrite (T *value_) ZMQ_FINAL
|
bool unwrite (T *value_)
|
||||||
{
|
{
|
||||||
if (_f == &_queue.back ())
|
if (_f == &_queue.back ())
|
||||||
return false;
|
return false;
|
||||||
@@ -100,7 +100,7 @@ template <typename T, int N> class ypipe_t ZMQ_FINAL : public ypipe_base_t<T>
|
|||||||
// Flush all the completed items into the pipe. Returns false if
|
// Flush all the completed items into the pipe. Returns false if
|
||||||
// the reader thread is sleeping. In that case, caller is obliged to
|
// the reader thread is sleeping. In that case, caller is obliged to
|
||||||
// wake the reader up before using the pipe again.
|
// wake the reader up before using the pipe again.
|
||||||
inline bool flush () ZMQ_FINAL
|
bool flush ()
|
||||||
{
|
{
|
||||||
// If there are no un-flushed items, do nothing.
|
// If there are no un-flushed items, do nothing.
|
||||||
if (_w == _f)
|
if (_w == _f)
|
||||||
@@ -125,7 +125,7 @@ template <typename T, int N> class ypipe_t ZMQ_FINAL : public ypipe_base_t<T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check whether item is available for reading.
|
// Check whether item is available for reading.
|
||||||
inline bool check_read () ZMQ_FINAL
|
bool check_read ()
|
||||||
{
|
{
|
||||||
// Was the value prefetched already? If so, return.
|
// Was the value prefetched already? If so, return.
|
||||||
if (&_queue.front () != _r && _r)
|
if (&_queue.front () != _r && _r)
|
||||||
@@ -150,7 +150,7 @@ template <typename T, int N> class ypipe_t ZMQ_FINAL : public ypipe_base_t<T>
|
|||||||
|
|
||||||
// Reads an item from the pipe. Returns false if there is no value.
|
// Reads an item from the pipe. Returns false if there is no value.
|
||||||
// available.
|
// available.
|
||||||
inline bool read (T *value_) ZMQ_FINAL
|
bool read (T *value_)
|
||||||
{
|
{
|
||||||
// Try to prefetch a value.
|
// Try to prefetch a value.
|
||||||
if (!check_read ())
|
if (!check_read ())
|
||||||
@@ -166,7 +166,7 @@ template <typename T, int N> class ypipe_t ZMQ_FINAL : public ypipe_base_t<T>
|
|||||||
// Applies the function fn to the first elemenent in the pipe
|
// Applies the function fn to the first elemenent in the pipe
|
||||||
// and returns the value returned by the fn.
|
// and returns the value returned by the fn.
|
||||||
// The pipe mustn't be empty or the function crashes.
|
// The pipe mustn't be empty or the function crashes.
|
||||||
inline bool probe (bool (*fn_) (const T &)) ZMQ_FINAL
|
bool probe (bool (*fn_) (const T &))
|
||||||
{
|
{
|
||||||
const bool rc = check_read ();
|
const bool rc = check_read ();
|
||||||
zmq_assert (rc);
|
zmq_assert (rc);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ template <typename T> class ypipe_conflate_t ZMQ_FINAL : public ypipe_base_t<T>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Initialises the pipe.
|
// Initialises the pipe.
|
||||||
inline ypipe_conflate_t () : reader_awake (false) {}
|
ypipe_conflate_t () : reader_awake (false) {}
|
||||||
|
|
||||||
// Following function (write) deliberately copies uninitialised data
|
// Following function (write) deliberately copies uninitialised data
|
||||||
// when used with zmq_msg. Initialising the VSM body for
|
// when used with zmq_msg. Initialising the VSM body for
|
||||||
@@ -57,7 +57,7 @@ template <typename T> class ypipe_conflate_t ZMQ_FINAL : public ypipe_base_t<T>
|
|||||||
#pragma message save
|
#pragma message save
|
||||||
#pragma message disable(UNINIT)
|
#pragma message disable(UNINIT)
|
||||||
#endif
|
#endif
|
||||||
inline void write (const T &value_, bool incomplete_) ZMQ_FINAL
|
void write (const T &value_, bool incomplete_)
|
||||||
{
|
{
|
||||||
(void) incomplete_;
|
(void) incomplete_;
|
||||||
|
|
||||||
@@ -69,16 +69,16 @@ template <typename T> class ypipe_conflate_t ZMQ_FINAL : public ypipe_base_t<T>
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// There are no incomplete items for conflate ypipe
|
// There are no incomplete items for conflate ypipe
|
||||||
inline bool unwrite (T *) ZMQ_FINAL { return false; }
|
bool unwrite (T *) { return false; }
|
||||||
|
|
||||||
// Flush is no-op for conflate ypipe. Reader asleep behaviour
|
// Flush is no-op for conflate ypipe. Reader asleep behaviour
|
||||||
// is as of the usual ypipe.
|
// is as of the usual ypipe.
|
||||||
// Returns false if the reader thread is sleeping. In that case,
|
// Returns false if the reader thread is sleeping. In that case,
|
||||||
// caller is obliged to wake the reader up before using the pipe again.
|
// caller is obliged to wake the reader up before using the pipe again.
|
||||||
inline bool flush () ZMQ_FINAL { return reader_awake; }
|
bool flush () { return reader_awake; }
|
||||||
|
|
||||||
// Check whether item is available for reading.
|
// Check whether item is available for reading.
|
||||||
inline bool check_read () ZMQ_FINAL
|
bool check_read ()
|
||||||
{
|
{
|
||||||
const bool res = dbuffer.check_read ();
|
const bool res = dbuffer.check_read ();
|
||||||
if (!res)
|
if (!res)
|
||||||
@@ -89,7 +89,7 @@ template <typename T> class ypipe_conflate_t ZMQ_FINAL : public ypipe_base_t<T>
|
|||||||
|
|
||||||
// Reads an item from the pipe. Returns false if there is no value.
|
// Reads an item from the pipe. Returns false if there is no value.
|
||||||
// available.
|
// available.
|
||||||
inline bool read (T *value_) ZMQ_FINAL
|
bool read (T *value_)
|
||||||
{
|
{
|
||||||
if (!check_read ())
|
if (!check_read ())
|
||||||
return false;
|
return false;
|
||||||
@@ -100,10 +100,7 @@ template <typename T> class ypipe_conflate_t ZMQ_FINAL : public ypipe_base_t<T>
|
|||||||
// Applies the function fn to the first elemenent in the pipe
|
// Applies the function fn to the first elemenent in the pipe
|
||||||
// and returns the value returned by the fn.
|
// and returns the value returned by the fn.
|
||||||
// The pipe mustn't be empty or the function crashes.
|
// The pipe mustn't be empty or the function crashes.
|
||||||
inline bool probe (bool (*fn_) (const T &)) ZMQ_FINAL
|
bool probe (bool (*fn_) (const T &)) { return dbuffer.probe (fn_); }
|
||||||
{
|
|
||||||
return dbuffer.probe (fn_);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
dbuffer_t<T> dbuffer;
|
dbuffer_t<T> dbuffer;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace zmq
|
|||||||
class zap_client_t : public virtual mechanism_base_t
|
class zap_client_t : public virtual mechanism_base_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
zap_client_t (session_base_t *const session_,
|
zap_client_t (session_base_t *session_,
|
||||||
const std::string &peer_address_,
|
const std::string &peer_address_,
|
||||||
const options_t &options_);
|
const options_t &options_);
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ class zap_client_common_handshake_t : public zap_client_t
|
|||||||
ready
|
ready
|
||||||
};
|
};
|
||||||
|
|
||||||
zap_client_common_handshake_t (session_base_t *const session_,
|
zap_client_common_handshake_t (session_base_t *session_,
|
||||||
const std::string &peer_address_,
|
const std::string &peer_address_,
|
||||||
const options_t &options_,
|
const options_t &options_,
|
||||||
state_t zap_reply_ok_state_);
|
state_t zap_reply_ok_state_);
|
||||||
|
|||||||
@@ -65,18 +65,18 @@ class zmtp_engine_t ZMQ_FINAL : public stream_engine_base_t
|
|||||||
zmtp_engine_t (fd_t fd_,
|
zmtp_engine_t (fd_t fd_,
|
||||||
const options_t &options_,
|
const options_t &options_,
|
||||||
const endpoint_uri_pair_t &endpoint_uri_pair_);
|
const endpoint_uri_pair_t &endpoint_uri_pair_);
|
||||||
~zmtp_engine_t () ZMQ_FINAL;
|
~zmtp_engine_t ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Detects the protocol used by the peer.
|
// Detects the protocol used by the peer.
|
||||||
bool handshake () ZMQ_FINAL;
|
bool handshake ();
|
||||||
|
|
||||||
void plug_internal () ZMQ_FINAL;
|
void plug_internal ();
|
||||||
|
|
||||||
int process_command_message (msg_t *msg_) ZMQ_FINAL;
|
int process_command_message (msg_t *msg_);
|
||||||
int produce_ping_message (msg_t *msg_) ZMQ_FINAL;
|
int produce_ping_message (msg_t *msg_);
|
||||||
int process_heartbeat_message (msg_t *msg_) ZMQ_FINAL;
|
int process_heartbeat_message (msg_t *msg_);
|
||||||
int produce_pong_message (msg_t *msg_) ZMQ_FINAL;
|
int produce_pong_message (msg_t *msg_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Receive the greeting from the peer.
|
// Receive the greeting from the peer.
|
||||||
|
|||||||
Reference in New Issue
Block a user