Commit beffee92 authored by Martin Sustrik's avatar Martin Sustrik

P2P renamed to PAIR

parent 7d9603d7
...@@ -26,12 +26,12 @@ Peer to peer pattern ...@@ -26,12 +26,12 @@ Peer to peer pattern
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
The simplest messaging pattern, used for communicating between two peers. The simplest messaging pattern, used for communicating between two peers.
Socket type:: 'ZMQ_P2P' Socket type:: 'ZMQ_PAIR'
Compatible peer sockets:: 'ZMQ_P2P' 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 time. No message routing or filtering is performed on messages sent over a
'ZMQ_P2P' socket. 'ZMQ_PAIR' socket.
Publish-subscribe pattern Publish-subscribe pattern
......
...@@ -153,7 +153,9 @@ ZMQ_EXPORT int zmq_term (void *context); ...@@ -153,7 +153,9 @@ ZMQ_EXPORT int zmq_term (void *context);
/* 0MQ socket definition. */ /* 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_P2P 0
#define ZMQ_PUB 1 #define ZMQ_PUB 1
#define ZMQ_SUB 2 #define ZMQ_SUB 2
......
...@@ -90,7 +90,7 @@ libzmq_la_SOURCES = app_thread.hpp \ ...@@ -90,7 +90,7 @@ libzmq_la_SOURCES = app_thread.hpp \
platform.hpp \ platform.hpp \
poll.hpp \ poll.hpp \
poller.hpp \ poller.hpp \
p2p.hpp \ pair.hpp \
prefix_tree.hpp \ prefix_tree.hpp \
pub.hpp \ pub.hpp \
queue.hpp \ queue.hpp \
...@@ -145,7 +145,7 @@ libzmq_la_SOURCES = app_thread.hpp \ ...@@ -145,7 +145,7 @@ libzmq_la_SOURCES = app_thread.hpp \
pgm_receiver.cpp \ pgm_receiver.cpp \
pgm_sender.cpp \ pgm_sender.cpp \
pgm_socket.cpp \ pgm_socket.cpp \
p2p.cpp \ pair.cpp \
prefix_tree.cpp \ prefix_tree.cpp \
pipe.cpp \ pipe.cpp \
poll.cpp \ poll.cpp \
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include "pipe.hpp" #include "pipe.hpp"
#include "config.hpp" #include "config.hpp"
#include "socket_base.hpp" #include "socket_base.hpp"
#include "p2p.hpp" #include "pair.hpp"
#include "pub.hpp" #include "pub.hpp"
#include "sub.hpp" #include "sub.hpp"
#include "req.hpp" #include "req.hpp"
...@@ -152,8 +152,8 @@ zmq::socket_base_t *zmq::app_thread_t::create_socket (int type_) ...@@ -152,8 +152,8 @@ zmq::socket_base_t *zmq::app_thread_t::create_socket (int type_)
{ {
socket_base_t *s = NULL; socket_base_t *s = NULL;
switch (type_) { switch (type_) {
case ZMQ_P2P: case ZMQ_PAIR:
s = new (std::nothrow) p2p_t (this); s = new (std::nothrow) pair_t (this);
break; break;
case ZMQ_PUB: case ZMQ_PUB:
s = new (std::nothrow) pub_t (this); s = new (std::nothrow) pub_t (this);
......
...@@ -19,11 +19,11 @@ ...@@ -19,11 +19,11 @@
#include "../include/zmq.h" #include "../include/zmq.h"
#include "p2p.hpp" #include "pair.hpp"
#include "err.hpp" #include "err.hpp"
#include "pipe.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_), socket_base_t (parent_),
inpipe (NULL), inpipe (NULL),
outpipe (NULL), outpipe (NULL),
...@@ -33,7 +33,7 @@ zmq::p2p_t::p2p_t (class app_thread_t *parent_) : ...@@ -33,7 +33,7 @@ zmq::p2p_t::p2p_t (class app_thread_t *parent_) :
options.requires_out = true; options.requires_out = true;
} }
zmq::p2p_t::~p2p_t () zmq::pair_t::~pair_t ()
{ {
if (inpipe) if (inpipe)
inpipe->term (); inpipe->term ();
...@@ -41,7 +41,7 @@ zmq::p2p_t::~p2p_t () ...@@ -41,7 +41,7 @@ zmq::p2p_t::~p2p_t ()
outpipe->term (); 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_) class writer_t *outpipe_, const blob_t &peer_identity_)
{ {
zmq_assert (!inpipe && !outpipe); zmq_assert (!inpipe && !outpipe);
...@@ -50,44 +50,44 @@ void zmq::p2p_t::xattach_pipes (class reader_t *inpipe_, ...@@ -50,44 +50,44 @@ void zmq::p2p_t::xattach_pipes (class reader_t *inpipe_,
outpipe_alive = true; 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); zmq_assert (pipe_ == inpipe);
inpipe = NULL; 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); zmq_assert (pipe_ == outpipe);
outpipe = NULL; outpipe = NULL;
} }
void zmq::p2p_t::xkill (class reader_t *pipe_) void zmq::pair_t::xkill (class reader_t *pipe_)
{ {
zmq_assert (alive); zmq_assert (alive);
alive = false; alive = false;
} }
void zmq::p2p_t::xrevive (class reader_t *pipe_) void zmq::pair_t::xrevive (class reader_t *pipe_)
{ {
zmq_assert (!alive); zmq_assert (!alive);
alive = true; alive = true;
} }
void zmq::p2p_t::xrevive (class writer_t *pipe_) void zmq::pair_t::xrevive (class writer_t *pipe_)
{ {
zmq_assert (!outpipe_alive); zmq_assert (!outpipe_alive);
outpipe_alive = true; 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_) size_t optvallen_)
{ {
errno = EINVAL; errno = EINVAL;
return -1; 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) { if (outpipe == NULL || !outpipe_alive) {
errno = EAGAIN; errno = EAGAIN;
...@@ -109,7 +109,7 @@ int zmq::p2p_t::xsend (zmq_msg_t *msg_, int flags_) ...@@ -109,7 +109,7 @@ int zmq::p2p_t::xsend (zmq_msg_t *msg_, int flags_)
return 0; 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. // Deallocate old content of the message.
zmq_msg_close (msg_); zmq_msg_close (msg_);
...@@ -121,14 +121,14 @@ int zmq::p2p_t::xrecv (zmq_msg_t *msg_, int flags_) ...@@ -121,14 +121,14 @@ int zmq::p2p_t::xrecv (zmq_msg_t *msg_, int flags_)
return 0; return 0;
} }
bool zmq::p2p_t::xhas_in () bool zmq::pair_t::xhas_in ()
{ {
if (alive && inpipe && inpipe->check_read ()) if (alive && inpipe && inpipe->check_read ())
return true; return true;
return false; return false;
} }
bool zmq::p2p_t::xhas_out () bool zmq::pair_t::xhas_out ()
{ {
if (outpipe == NULL || !outpipe_alive) if (outpipe == NULL || !outpipe_alive)
return false; return false;
......
...@@ -17,20 +17,20 @@ ...@@ -17,20 +17,20 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __ZMQ_P2P_HPP_INCLUDED__ #ifndef __ZMQ_PAIR_HPP_INCLUDED__
#define __ZMQ_P2P_HPP_INCLUDED__ #define __ZMQ_PAIR_HPP_INCLUDED__
#include "socket_base.hpp" #include "socket_base.hpp"
namespace zmq namespace zmq
{ {
class p2p_t : public socket_base_t class pair_t : public socket_base_t
{ {
public: public:
p2p_t (class app_thread_t *parent_); pair_t (class app_thread_t *parent_);
~p2p_t (); ~pair_t ();
// Overloads of functions from socket_base_t. // Overloads of functions from socket_base_t.
void xattach_pipes (class reader_t *inpipe_, class writer_t *outpipe_, void xattach_pipes (class reader_t *inpipe_, class writer_t *outpipe_,
...@@ -54,8 +54,8 @@ namespace zmq ...@@ -54,8 +54,8 @@ namespace zmq
bool alive; bool alive;
bool outpipe_alive; bool outpipe_alive;
p2p_t (const p2p_t&); pair_t (const pair_t&);
void operator = (const p2p_t&); void operator = (const pair_t&);
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment