Removed unused template parameter from network stack.

Reviewers: mislav.bradac, buda

Reviewed By: buda

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D632
This commit is contained in:
Matej Ferencevic 2017-08-04 10:49:00 +02:00
parent d750970381
commit 7939b04117
5 changed files with 10 additions and 20 deletions

View File

@ -30,14 +30,12 @@ namespace communication {
* @tparam Session the server can handle different Sessions, each session * @tparam Session the server can handle different Sessions, each session
* represents a different protocol so the same network infrastructure * represents a different protocol so the same network infrastructure
* can be used for handling different protocols * can be used for handling different protocols
* @tparam OutputStream the server has to get the output stream as a template
parameter because the output stream is templated
* @tparam Socket the input/output socket that should be used * @tparam Socket the input/output socket that should be used
* @tparam SessionData the class with objects that will be forwarded to the session * @tparam SessionData the class with objects that will be forwarded to the session
*/ */
template <typename Session, typename OutputStream, typename Socket, typename SessionData> template <typename Session, typename Socket, typename SessionData>
class Server class Server
: public io::network::EventListener<Server<Session, OutputStream, Socket, SessionData>> { : public io::network::EventListener<Server<Session, Socket, SessionData>> {
using Event = io::network::Epoll::Event; using Event = io::network::Epoll::Event;
public: public:
@ -58,7 +56,7 @@ class Server
workers_.reserve(n); workers_.reserve(n);
for (size_t i = 0; i < n; ++i) { for (size_t i = 0; i < n; ++i) {
workers_.push_back( workers_.push_back(
std::make_unique<Worker<Session, OutputStream, Socket, SessionData>>( std::make_unique<Worker<Session, Socket, SessionData>>(
session_data_)); session_data_));
workers_.back()->Start(alive_); workers_.back()->Start(alive_);
} }
@ -110,7 +108,7 @@ class Server
void OnErrorEvent(Event &event) { close(event.data.fd); } void OnErrorEvent(Event &event) { close(event.data.fd); }
private: private:
std::vector<typename Worker<Session, OutputStream, Socket, SessionData>::uptr> workers_; std::vector<typename Worker<Session, Socket, SessionData>::uptr> workers_;
std::atomic<bool> alive_{true}; std::atomic<bool> alive_{true};
int idx_{0}; int idx_{0};

View File

@ -26,20 +26,18 @@ namespace communication {
* @tparam Session the worker can handle different Sessions, each session * @tparam Session the worker can handle different Sessions, each session
* represents a different protocol so the same network infrastructure * represents a different protocol so the same network infrastructure
* can be used for handling different protocols * can be used for handling different protocols
* @tparam OutputStream the worker has to get the output stream as a template
parameter because the output stream is templated
* @tparam Socket the input/output socket that should be used * @tparam Socket the input/output socket that should be used
* @tparam SessionData the class with objects that will be forwarded to the session * @tparam SessionData the class with objects that will be forwarded to the session
*/ */
template <typename Session, typename OutputStream, typename Socket, typename SessionData> template <typename Session, typename Socket, typename SessionData>
class Worker class Worker
: public io::network::StreamReader<Worker<Session, OutputStream, Socket, SessionData>, : public io::network::StreamReader<Worker<Session, Socket, SessionData>,
Session> { Session> {
using StreamBuffer = io::network::StreamBuffer; using StreamBuffer = io::network::StreamBuffer;
public: public:
using uptr = std::unique_ptr<Worker<Session, OutputStream, Socket, SessionData>>; using uptr = std::unique_ptr<Worker<Session, Socket, SessionData>>;
Worker(SessionData &session_data) : session_data_(session_data) {} Worker(SessionData &session_data) : session_data_(session_data) {}

View File

@ -25,7 +25,7 @@ using result_stream_t =
communication::bolt::ChunkedEncoderBuffer<socket_t>>>; communication::bolt::ChunkedEncoderBuffer<socket_t>>>;
using session_data_t = communication::bolt::SessionData<result_stream_t>; using session_data_t = communication::bolt::SessionData<result_stream_t>;
using bolt_server_t = using bolt_server_t =
communication::Server<session_t, result_stream_t, socket_t, session_data_t>; communication::Server<session_t, socket_t, session_data_t>;
DEFINE_string(interface, "0.0.0.0", "Default interface on which to listen."); DEFINE_string(interface, "0.0.0.0", "Default interface on which to listen.");
DEFINE_string(port, "7687", "Default port on which to listen."); DEFINE_string(port, "7687", "Default port on which to listen.");

View File

@ -21,8 +21,6 @@ static constexpr const int REPLY = 10;
using endpoint_t = io::network::NetworkEndpoint; using endpoint_t = io::network::NetworkEndpoint;
using socket_t = io::network::Socket; using socket_t = io::network::Socket;
class TestOutputStream {};
class TestData {}; class TestData {};
class TestSession { class TestSession {
@ -64,8 +62,7 @@ class TestSession {
io::network::Epoll::Event event_; io::network::Epoll::Event event_;
}; };
using test_server_t = using test_server_t = communication::Server<TestSession, socket_t, TestData>;
communication::Server<TestSession, TestOutputStream, socket_t, TestData>;
void server_start(void *serverptr, int num) { void server_start(void *serverptr, int num) {
((test_server_t *)serverptr)->Start(num); ((test_server_t *)serverptr)->Start(num);

View File

@ -23,8 +23,6 @@ static constexpr const char interface[] = "127.0.0.1";
using endpoint_t = io::network::NetworkEndpoint; using endpoint_t = io::network::NetworkEndpoint;
using socket_t = io::network::Socket; using socket_t = io::network::Socket;
class TestOutputStream {};
class TestData {}; class TestData {};
class TestSession { class TestSession {
@ -51,8 +49,7 @@ class TestSession {
io::network::Epoll::Event event_; io::network::Epoll::Event event_;
}; };
using test_server_t = using test_server_t = communication::Server<TestSession, socket_t, TestData>;
communication::Server<TestSession, TestOutputStream, socket_t, TestData>;
test_server_t *serverptr; test_server_t *serverptr;
std::atomic<bool> run{true}; std::atomic<bool> run{true};