P2P renamed to PAIR

This commit is contained in:
Martin Sustrik 2010-04-26 16:51:05 +02:00
parent 7d9603d722
commit beffee92a8
6 changed files with 33 additions and 31 deletions

View File

@ -26,12 +26,12 @@ Peer to peer pattern
~~~~~~~~~~~~~~~~~~~~
The simplest messaging pattern, used for communicating between two peers.
Socket type:: 'ZMQ_P2P'
Compatible peer sockets:: 'ZMQ_P2P'
Socket type:: 'ZMQ_PAIR'
Compatible peer sockets:: 'ZMQ_PAIR'
A socket of type 'ZMQ_P2P' can only be connected to a single peer at any one
A socket of type 'ZMQ_PAIR' can only be connected to a single peer at any one
time. No message routing or filtering is performed on messages sent over a
'ZMQ_P2P' socket.
'ZMQ_PAIR' socket.
Publish-subscribe pattern

View File

@ -153,7 +153,9 @@ ZMQ_EXPORT int zmq_term (void *context);
/* 0MQ socket definition. */
/******************************************************************************/
/* Socket types. */
/* Socket types. */
/* ZMQ_P2P is obsolete and scheduled to be removed in version 2.0.8 */
#define ZMQ_PAIR 0
#define ZMQ_P2P 0
#define ZMQ_PUB 1
#define ZMQ_SUB 2

View File

@ -90,7 +90,7 @@ libzmq_la_SOURCES = app_thread.hpp \
platform.hpp \
poll.hpp \
poller.hpp \
p2p.hpp \
pair.hpp \
prefix_tree.hpp \
pub.hpp \
queue.hpp \
@ -145,7 +145,7 @@ libzmq_la_SOURCES = app_thread.hpp \
pgm_receiver.cpp \
pgm_sender.cpp \
pgm_socket.cpp \
p2p.cpp \
pair.cpp \
prefix_tree.cpp \
pipe.cpp \
poll.cpp \

View File

@ -41,7 +41,7 @@
#include "pipe.hpp"
#include "config.hpp"
#include "socket_base.hpp"
#include "p2p.hpp"
#include "pair.hpp"
#include "pub.hpp"
#include "sub.hpp"
#include "req.hpp"
@ -152,8 +152,8 @@ zmq::socket_base_t *zmq::app_thread_t::create_socket (int type_)
{
socket_base_t *s = NULL;
switch (type_) {
case ZMQ_P2P:
s = new (std::nothrow) p2p_t (this);
case ZMQ_PAIR:
s = new (std::nothrow) pair_t (this);
break;
case ZMQ_PUB:
s = new (std::nothrow) pub_t (this);

View File

@ -19,11 +19,11 @@
#include "../include/zmq.h"
#include "p2p.hpp"
#include "pair.hpp"
#include "err.hpp"
#include "pipe.hpp"
zmq::p2p_t::p2p_t (class app_thread_t *parent_) :
zmq::pair_t::pair_t (class app_thread_t *parent_) :
socket_base_t (parent_),
inpipe (NULL),
outpipe (NULL),
@ -33,7 +33,7 @@ zmq::p2p_t::p2p_t (class app_thread_t *parent_) :
options.requires_out = true;
}
zmq::p2p_t::~p2p_t ()
zmq::pair_t::~pair_t ()
{
if (inpipe)
inpipe->term ();
@ -41,7 +41,7 @@ zmq::p2p_t::~p2p_t ()
outpipe->term ();
}
void zmq::p2p_t::xattach_pipes (class reader_t *inpipe_,
void zmq::pair_t::xattach_pipes (class reader_t *inpipe_,
class writer_t *outpipe_, const blob_t &peer_identity_)
{
zmq_assert (!inpipe && !outpipe);
@ -50,44 +50,44 @@ void zmq::p2p_t::xattach_pipes (class reader_t *inpipe_,
outpipe_alive = true;
}
void zmq::p2p_t::xdetach_inpipe (class reader_t *pipe_)
void zmq::pair_t::xdetach_inpipe (class reader_t *pipe_)
{
zmq_assert (pipe_ == inpipe);
inpipe = NULL;
}
void zmq::p2p_t::xdetach_outpipe (class writer_t *pipe_)
void zmq::pair_t::xdetach_outpipe (class writer_t *pipe_)
{
zmq_assert (pipe_ == outpipe);
outpipe = NULL;
}
void zmq::p2p_t::xkill (class reader_t *pipe_)
void zmq::pair_t::xkill (class reader_t *pipe_)
{
zmq_assert (alive);
alive = false;
}
void zmq::p2p_t::xrevive (class reader_t *pipe_)
void zmq::pair_t::xrevive (class reader_t *pipe_)
{
zmq_assert (!alive);
alive = true;
}
void zmq::p2p_t::xrevive (class writer_t *pipe_)
void zmq::pair_t::xrevive (class writer_t *pipe_)
{
zmq_assert (!outpipe_alive);
outpipe_alive = true;
}
int zmq::p2p_t::xsetsockopt (int option_, const void *optval_,
int zmq::pair_t::xsetsockopt (int option_, const void *optval_,
size_t optvallen_)
{
errno = EINVAL;
return -1;
}
int zmq::p2p_t::xsend (zmq_msg_t *msg_, int flags_)
int zmq::pair_t::xsend (zmq_msg_t *msg_, int flags_)
{
if (outpipe == NULL || !outpipe_alive) {
errno = EAGAIN;
@ -109,7 +109,7 @@ int zmq::p2p_t::xsend (zmq_msg_t *msg_, int flags_)
return 0;
}
int zmq::p2p_t::xrecv (zmq_msg_t *msg_, int flags_)
int zmq::pair_t::xrecv (zmq_msg_t *msg_, int flags_)
{
// Deallocate old content of the message.
zmq_msg_close (msg_);
@ -121,14 +121,14 @@ int zmq::p2p_t::xrecv (zmq_msg_t *msg_, int flags_)
return 0;
}
bool zmq::p2p_t::xhas_in ()
bool zmq::pair_t::xhas_in ()
{
if (alive && inpipe && inpipe->check_read ())
return true;
return false;
}
bool zmq::p2p_t::xhas_out ()
bool zmq::pair_t::xhas_out ()
{
if (outpipe == NULL || !outpipe_alive)
return false;

View File

@ -17,20 +17,20 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __ZMQ_P2P_HPP_INCLUDED__
#define __ZMQ_P2P_HPP_INCLUDED__
#ifndef __ZMQ_PAIR_HPP_INCLUDED__
#define __ZMQ_PAIR_HPP_INCLUDED__
#include "socket_base.hpp"
namespace zmq
{
class p2p_t : public socket_base_t
class pair_t : public socket_base_t
{
public:
p2p_t (class app_thread_t *parent_);
~p2p_t ();
pair_t (class app_thread_t *parent_);
~pair_t ();
// Overloads of functions from socket_base_t.
void xattach_pipes (class reader_t *inpipe_, class writer_t *outpipe_,
@ -54,8 +54,8 @@ namespace zmq
bool alive;
bool outpipe_alive;
p2p_t (const p2p_t&);
void operator = (const p2p_t&);
pair_t (const pair_t&);
void operator = (const pair_t&);
};
}