mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-12 10:33:52 +01:00
redundant interface (i_api) removed
This commit is contained in:
parent
9f1f823b7b
commit
bda766ab40
@ -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 \
|
||||
|
@ -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).
|
||||
|
@ -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.
|
||||
|
@ -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 ();
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -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
|
||||
|
@ -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:
|
||||
|
||||
|
19
src/zmq.cpp
19
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_));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user