mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-04 07:27:26 +01:00
ZMQ_GENERIC renamed to ZMQ_ROUTER
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
This commit is contained in:
parent
cb2d715605
commit
72a793f78a
@ -158,7 +158,7 @@ ZMQ_EXPORT int zmq_term (void *context);
|
||||
#define ZMQ_PUSH 8
|
||||
#define ZMQ_XPUB 9
|
||||
#define ZMQ_XSUB 10
|
||||
#define ZMQ_GENERIC 13
|
||||
#define ZMQ_ROUTER 13
|
||||
|
||||
/* Socket options. */
|
||||
#define ZMQ_AFFINITY 4
|
||||
|
@ -23,7 +23,6 @@ libzmq_la_SOURCES = \
|
||||
err.hpp \
|
||||
fd.hpp \
|
||||
fq.hpp \
|
||||
generic.hpp \
|
||||
io_object.hpp \
|
||||
io_thread.hpp \
|
||||
ip.hpp \
|
||||
@ -55,6 +54,7 @@ libzmq_la_SOURCES = \
|
||||
reaper.hpp \
|
||||
rep.hpp \
|
||||
req.hpp \
|
||||
router.hpp \
|
||||
select.hpp \
|
||||
semaphore.hpp \
|
||||
session.hpp \
|
||||
@ -89,7 +89,6 @@ libzmq_la_SOURCES = \
|
||||
epoll.cpp \
|
||||
err.cpp \
|
||||
fq.cpp \
|
||||
generic.cpp \
|
||||
io_object.cpp \
|
||||
io_thread.cpp \
|
||||
ip.cpp \
|
||||
@ -113,6 +112,7 @@ libzmq_la_SOURCES = \
|
||||
reaper.cpp \
|
||||
pub.cpp \
|
||||
random.cpp \
|
||||
router.cpp \
|
||||
rep.cpp \
|
||||
req.cpp \
|
||||
select.cpp \
|
||||
|
@ -18,7 +18,7 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "generic.hpp"
|
||||
#include "router.hpp"
|
||||
#include "pipe.hpp"
|
||||
#include "wire.hpp"
|
||||
#include "random.hpp"
|
||||
@ -26,7 +26,7 @@
|
||||
#include "wire.hpp"
|
||||
#include "err.hpp"
|
||||
|
||||
zmq::generic_t::generic_t (class ctx_t *parent_, uint32_t tid_) :
|
||||
zmq::router_t::router_t (class ctx_t *parent_, uint32_t tid_) :
|
||||
socket_base_t (parent_, tid_),
|
||||
prefetched (false),
|
||||
more_in (false),
|
||||
@ -34,18 +34,18 @@ zmq::generic_t::generic_t (class ctx_t *parent_, uint32_t tid_) :
|
||||
more_out (false),
|
||||
next_peer_id (generate_random ())
|
||||
{
|
||||
options.type = ZMQ_GENERIC;
|
||||
options.type = ZMQ_ROUTER;
|
||||
|
||||
prefetched_msg.init ();
|
||||
}
|
||||
|
||||
zmq::generic_t::~generic_t ()
|
||||
zmq::router_t::~router_t ()
|
||||
{
|
||||
zmq_assert (outpipes.empty ());
|
||||
prefetched_msg.close ();
|
||||
}
|
||||
|
||||
void zmq::generic_t::xattach_pipe (pipe_t *pipe_)
|
||||
void zmq::router_t::xattach_pipe (pipe_t *pipe_)
|
||||
{
|
||||
zmq_assert (pipe_);
|
||||
|
||||
@ -82,7 +82,7 @@ void zmq::generic_t::xattach_pipe (pipe_t *pipe_)
|
||||
++next_peer_id;
|
||||
}
|
||||
|
||||
void zmq::generic_t::xterminated (pipe_t *pipe_)
|
||||
void zmq::router_t::xterminated (pipe_t *pipe_)
|
||||
{
|
||||
fq.terminated (pipe_);
|
||||
|
||||
@ -104,12 +104,12 @@ void zmq::generic_t::xterminated (pipe_t *pipe_)
|
||||
zmq_assert (false);
|
||||
}
|
||||
|
||||
void zmq::generic_t::xread_activated (pipe_t *pipe_)
|
||||
void zmq::router_t::xread_activated (pipe_t *pipe_)
|
||||
{
|
||||
fq.activated (pipe_);
|
||||
}
|
||||
|
||||
void zmq::generic_t::xwrite_activated (pipe_t *pipe_)
|
||||
void zmq::router_t::xwrite_activated (pipe_t *pipe_)
|
||||
{
|
||||
for (outpipes_t::iterator it = outpipes.begin ();
|
||||
it != outpipes.end (); ++it) {
|
||||
@ -122,7 +122,7 @@ void zmq::generic_t::xwrite_activated (pipe_t *pipe_)
|
||||
zmq_assert (false);
|
||||
}
|
||||
|
||||
int zmq::generic_t::xsend (msg_t *msg_, int flags_)
|
||||
int zmq::router_t::xsend (msg_t *msg_, int flags_)
|
||||
{
|
||||
// If this is the first part of the message it's the ID of the
|
||||
// peer to send the message to.
|
||||
@ -188,7 +188,7 @@ int zmq::generic_t::xsend (msg_t *msg_, int flags_)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int zmq::generic_t::xrecv (msg_t *msg_, int flags_)
|
||||
int zmq::router_t::xrecv (msg_t *msg_, int flags_)
|
||||
{
|
||||
// If there's a queued command, pass it to the caller.
|
||||
if (unlikely (!more_in && !pending_commands.empty ())) {
|
||||
@ -236,7 +236,7 @@ int zmq::generic_t::xrecv (msg_t *msg_, int flags_)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int zmq::generic_t::rollback (void)
|
||||
int zmq::router_t::rollback (void)
|
||||
{
|
||||
if (current_out) {
|
||||
current_out->rollback ();
|
||||
@ -246,14 +246,14 @@ int zmq::generic_t::rollback (void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool zmq::generic_t::xhas_in ()
|
||||
bool zmq::router_t::xhas_in ()
|
||||
{
|
||||
if (prefetched)
|
||||
return true;
|
||||
return fq.has_in ();
|
||||
}
|
||||
|
||||
bool zmq::generic_t::xhas_out ()
|
||||
bool zmq::router_t::xhas_out ()
|
||||
{
|
||||
// In theory, GENERIC socket is always ready for writing. Whether actual
|
||||
// attempt to write succeeds depends on whitch pipe the message is going
|
@ -18,8 +18,8 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __ZMQ_GENERIC_HPP_INCLUDED__
|
||||
#define __ZMQ_GENERIC_HPP_INCLUDED__
|
||||
#ifndef __ZMQ_ROUTER_HPP_INCLUDED__
|
||||
#define __ZMQ_ROUTER_HPP_INCLUDED__
|
||||
|
||||
#include <map>
|
||||
#include <deque>
|
||||
@ -32,14 +32,13 @@
|
||||
namespace zmq
|
||||
{
|
||||
|
||||
// TODO: This class uses O(n) scheduling. Rewrite it to use O(1) algorithm.
|
||||
class generic_t :
|
||||
class router_t :
|
||||
public socket_base_t
|
||||
{
|
||||
public:
|
||||
|
||||
generic_t (class ctx_t *parent_, uint32_t tid_);
|
||||
~generic_t ();
|
||||
router_t (class ctx_t *parent_, uint32_t tid_);
|
||||
~router_t ();
|
||||
|
||||
// Overloads of functions from socket_base_t.
|
||||
void xattach_pipe (class pipe_t *pipe_);
|
||||
@ -99,8 +98,8 @@ namespace zmq
|
||||
typedef std::deque <pending_command_t> pending_commands_t;
|
||||
pending_commands_t pending_commands;
|
||||
|
||||
generic_t (const generic_t&);
|
||||
const generic_t &operator = (const generic_t&);
|
||||
router_t (const router_t&);
|
||||
const router_t &operator = (const router_t&);
|
||||
};
|
||||
|
||||
}
|
@ -58,7 +58,7 @@
|
||||
#include "xrep.hpp"
|
||||
#include "xpub.hpp"
|
||||
#include "xsub.hpp"
|
||||
#include "generic.hpp"
|
||||
#include "router.hpp"
|
||||
|
||||
bool zmq::socket_base_t::check_tag ()
|
||||
{
|
||||
@ -104,8 +104,8 @@ zmq::socket_base_t *zmq::socket_base_t::create (int type_, class ctx_t *parent_,
|
||||
case ZMQ_XSUB:
|
||||
s = new (std::nothrow) xsub_t (parent_, tid_);
|
||||
break;
|
||||
case ZMQ_GENERIC:
|
||||
s = new (std::nothrow) generic_t (parent_, tid_);
|
||||
case ZMQ_ROUTER:
|
||||
s = new (std::nothrow) router_t (parent_, tid_);
|
||||
break;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user