summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/app_thread.cpp5
-rw-r--r--src/app_thread.hpp6
-rw-r--r--src/dispatcher.cpp3
-rw-r--r--src/dispatcher.hpp2
-rw-r--r--src/i_api.hpp43
-rw-r--r--src/i_poll_events.hpp60
-rw-r--r--src/socket_base.hpp21
-rw-r--r--src/zmq.cpp19
9 files changed, 57 insertions, 104 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 5d51725..8524067 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -18,11 +18,9 @@ libzmq_la_SOURCES = \
io_object.hpp \
io_thread.hpp \
ip.hpp \
- i_api.hpp \
i_poller.hpp \
i_poll_events.hpp \
i_signaler.hpp \
- i_socket.hpp \
kqueue.hpp \
msg.hpp \
mutex.hpp \
diff --git a/src/app_thread.cpp b/src/app_thread.cpp
index 3f76970..74ba357 100644
--- a/src/app_thread.cpp
+++ b/src/app_thread.cpp
@@ -28,7 +28,6 @@
#endif
#include "app_thread.hpp"
-#include "i_api.hpp"
#include "dispatcher.hpp"
#include "err.hpp"
#include "pipe.hpp"
@@ -130,7 +129,7 @@ void zmq::app_thread_t::process_commands (bool block_)
}
}
-zmq::i_api *zmq::app_thread_t::create_socket (int type_)
+zmq::socket_base_t *zmq::app_thread_t::create_socket (int type_)
{
// TODO: type is ignored for the time being.
socket_base_t *s = new socket_base_t (this);
@@ -139,7 +138,7 @@ zmq::i_api *zmq::app_thread_t::create_socket (int type_)
return s;
}
-void zmq::app_thread_t::remove_socket (i_api *socket_)
+void zmq::app_thread_t::remove_socket (socket_base_t *socket_)
{
// TODO: To speed this up we can possibly use the system where each socket
// holds its index (see I/O scheduler implementation).
diff --git a/src/app_thread.hpp b/src/app_thread.hpp
index 59e4a25..e7bbf70 100644
--- a/src/app_thread.hpp
+++ b/src/app_thread.hpp
@@ -56,15 +56,15 @@ namespace zmq
void process_commands (bool block_);
// Create a socket of a specified type.
- struct i_api *create_socket (int type_);
+ class socket_base_t *create_socket (int type_);
// Unregister the socket from the app_thread (called by socket itself).
- void remove_socket (struct i_api *socket_);
+ void remove_socket (class socket_base_t *socket_);
private:
// All the sockets created from this application thread.
- typedef std::vector <struct i_api*> sockets_t;
+ typedef std::vector <class socket_base_t*> sockets_t;
sockets_t sockets;
// Thread ID associated with this slot.
diff --git a/src/dispatcher.cpp b/src/dispatcher.cpp
index 0b68880..c0f4541 100644
--- a/src/dispatcher.cpp
+++ b/src/dispatcher.cpp
@@ -20,7 +20,6 @@
#include "../include/zmq.h"
#include "dispatcher.hpp"
-#include "i_api.hpp"
#include "app_thread.hpp"
#include "io_thread.hpp"
#include "platform.hpp"
@@ -98,7 +97,7 @@ int zmq::dispatcher_t::thread_slot_count ()
return signalers.size ();
}
-zmq::i_api *zmq::dispatcher_t::create_socket (int type_)
+zmq::socket_base_t *zmq::dispatcher_t::create_socket (int type_)
{
threads_sync.lock ();
app_thread_t *thread = choose_app_thread ();
diff --git a/src/dispatcher.hpp b/src/dispatcher.hpp
index 08ffab1..08596cb 100644
--- a/src/dispatcher.hpp
+++ b/src/dispatcher.hpp
@@ -55,7 +55,7 @@ namespace zmq
~dispatcher_t ();
// Create a socket.
- struct i_api *create_socket (int type_);
+ class socket_base_t *create_socket (int type_);
// Returns number of thread slots in the dispatcher. To be used by
// individual threads to find out how many distinct signals can be
diff --git a/src/i_api.hpp b/src/i_api.hpp
deleted file mode 100644
index e9bf1da..0000000
--- a/src/i_api.hpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- Copyright (c) 2007-2009 FastMQ Inc.
-
- This file is part of 0MQ.
-
- 0MQ is free software; you can redistribute it and/or modify it under
- the terms of the Lesser GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- 0MQ is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- Lesser GNU General Public License for more details.
-
- You should have received a copy of the Lesser GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef __ZMQ_I_API_HPP_INCLUDED__
-#define __ZMQ_I_API_HPP_INCLUDED__
-
-namespace zmq
-{
-
- struct i_api
- {
- virtual ~i_api () {}
-
- virtual int setsockopt (int option_, void *optval_,
- size_t optvallen_) = 0;
- virtual int bind (const char *addr_) = 0;
- virtual int connect (const char *addr_) = 0;
- virtual int subscribe (const char *criteria_) = 0;
- virtual int send (struct zmq_msg *msg_, int flags_) = 0;
- virtual int flush () = 0;
- virtual int recv (struct zmq_msg *msg_, int flags_) = 0;
- virtual int close () = 0;
- };
-
-}
-
-#endif
diff --git a/src/i_poll_events.hpp b/src/i_poll_events.hpp
index c065884..8893b45 100644
--- a/src/i_poll_events.hpp
+++ b/src/i_poll_events.hpp
@@ -1,45 +1,45 @@
/*
- Copyright (c) 2007-2009 FastMQ Inc.
-
- This file is part of 0MQ.
-
- 0MQ is free software; you can redistribute it and/or modify it under
- the terms of the Lesser GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- 0MQ is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- Lesser GNU General Public License for more details.
-
- You should have received a copy of the Lesser GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
+Copyright (c) 2007-2009 FastMQ Inc.
+
+This file is part of 0MQ.
+
+0MQ is free software; you can redistribute it and/or modify it under
+the terms of the Lesser GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+0MQ is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+Lesser GNU General Public License for more details.
+
+You should have received a copy of the Lesser GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
+
#ifndef __ZMQ_I_POLL_EVENTS_HPP_INCLUDED__
#define __ZMQ_I_POLL_EVENTS_HPP_INCLUDED__
-
+
namespace zmq
{
-
- // Virtual interface to be exposed by object that want to be notified
- // about events on file descriptors.
-
+
+ // Virtual interface to be exposed by object that want to be notified
+ // about events on file descriptors.
+
struct i_poll_events
{
virtual ~i_poll_events () {};
-
- // Called by I/O thread when file descriptor is ready for reading.
+
+ // Called by I/O thread when file descriptor is ready for reading.
virtual void in_event () = 0;
-
- // Called by I/O thread when file descriptor is ready for writing.
+
+ // Called by I/O thread when file descriptor is ready for writing.
virtual void out_event () = 0;
-
- // Called when timer expires.
+
+ // Called when timer expires.
virtual void timer_event () = 0;
};
-
+
}
-
+
#endif
diff --git a/src/socket_base.hpp b/src/socket_base.hpp
index 7f1c803..2257fbe 100644
--- a/src/socket_base.hpp
+++ b/src/socket_base.hpp
@@ -23,29 +23,28 @@
#include <set>
#include <string>
-#include "i_api.hpp"
#include "object.hpp"
#include "stdint.hpp"
namespace zmq
{
- class socket_base_t : public object_t, public i_api
+ class socket_base_t : public object_t
{
public:
socket_base_t (class app_thread_t *parent_);
~socket_base_t ();
- // i_api interface implementation.
- int setsockopt (int option_, void *optval_, size_t optvallen_);
- int bind (const char *addr_);
- int connect (const char *addr_);
- int subscribe (const char *criteria_);
- int send (struct zmq_msg *msg_, int flags_);
- int flush ();
- int recv (struct zmq_msg *msg_, int flags_);
- int close ();
+ // Interface for communication with the API layer.
+ virtual int setsockopt (int option_, void *optval_, size_t optvallen_);
+ virtual int bind (const char *addr_);
+ virtual int connect (const char *addr_);
+ virtual int subscribe (const char *criteria_);
+ virtual int send (struct zmq_msg *msg_, int flags_);
+ virtual int flush ();
+ virtual int recv (struct zmq_msg *msg_, int flags_);
+ virtual int close ();
private:
diff --git a/src/zmq.cpp b/src/zmq.cpp
index 1ea13bc..cca2a01 100644
--- a/src/zmq.cpp
+++ b/src/zmq.cpp
@@ -23,7 +23,7 @@
#include <stdlib.h>
#include <new>
-#include "i_api.hpp"
+#include "socket_base.hpp"
#include "err.hpp"
#include "dispatcher.hpp"
#include "msg.hpp"
@@ -188,41 +188,42 @@ void *zmq_socket (void *dispatcher_, int type_)
int zmq_close (void *s_)
{
- ((zmq::i_api*) s_)->close ();
+ ((zmq::socket_base_t*) s_)->close ();
return 0;
}
int zmq_setsockopt (void *s_, int option_, void *optval_, size_t optvallen_)
{
- return (((zmq::i_api*) s_)->setsockopt (option_, optval_, optvallen_));
+ return (((zmq::socket_base_t*) s_)->setsockopt (option_, optval_,
+ optvallen_));
}
int zmq_bind (void *s_, const char *addr_)
{
- return (((zmq::i_api*) s_)->bind (addr_));
+ return (((zmq::socket_base_t*) s_)->bind (addr_));
}
int zmq_connect (void *s_, const char *addr_)
{
- return (((zmq::i_api*) s_)->connect (addr_));
+ return (((zmq::socket_base_t*) s_)->connect (addr_));
}
int zmq_subscribe (void *s_, const char *criteria_)
{
- return (((zmq::i_api*) s_)->subscribe (criteria_));
+ return (((zmq::socket_base_t*) s_)->subscribe (criteria_));
}
int zmq_send (void *s_, zmq_msg *msg_, int flags_)
{
- return (((zmq::i_api*) s_)->send (msg_, flags_));
+ return (((zmq::socket_base_t*) s_)->send (msg_, flags_));
}
int zmq_flush (void *s_)
{
- return (((zmq::i_api*) s_)->flush ());
+ return (((zmq::socket_base_t*) s_)->flush ());
}
int zmq_recv (void *s_, zmq_msg *msg_, int flags_)
{
- return (((zmq::i_api*) s_)->recv (msg_, flags_));
+ return (((zmq::socket_base_t*) s_)->recv (msg_, flags_));
}