diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2016-12-20 14:41:39 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2016-12-20 15:50:29 +0100 |
commit | 51bc810507f2067ebd2646274d3cda5cb583a620 (patch) | |
tree | cbff1f6464262c2e6b3a622db93d044bab69a532 /fnet | |
parent | 530e52e17a85836d58cac58c89b71c189c6f9873 (diff) |
Further decouple some hpp files, config and the attributevector.
Diffstat (limited to 'fnet')
-rw-r--r-- | fnet/src/tests/connect_thread/connect_thread_test.cpp | 1 | ||||
-rw-r--r-- | fnet/src/vespa/fnet/connect_thread.h | 12 | ||||
-rw-r--r-- | fnet/src/vespa/fnet/connection.h | 3 | ||||
-rw-r--r-- | fnet/src/vespa/fnet/ext_connectable.h | 17 | ||||
-rw-r--r-- | fnet/src/vespa/fnet/transport.cpp | 14 | ||||
-rw-r--r-- | fnet/src/vespa/fnet/transport.h | 12 |
6 files changed, 39 insertions, 20 deletions
diff --git a/fnet/src/tests/connect_thread/connect_thread_test.cpp b/fnet/src/tests/connect_thread/connect_thread_test.cpp index f8492d147a6..b5304cf9b9e 100644 --- a/fnet/src/tests/connect_thread/connect_thread_test.cpp +++ b/fnet/src/tests/connect_thread/connect_thread_test.cpp @@ -2,6 +2,7 @@ #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/fnet/connect_thread.h> +#include <vespa/fnet/ext_connectable.h> struct MyConn : public fnet::ExtConnectable { bool connected = false; diff --git a/fnet/src/vespa/fnet/connect_thread.h b/fnet/src/vespa/fnet/connect_thread.h index 9782fa50a75..e963187f99d 100644 --- a/fnet/src/vespa/fnet/connect_thread.h +++ b/fnet/src/vespa/fnet/connect_thread.h @@ -3,6 +3,7 @@ #pragma once +#include "ext_connectable.h" #include <vespa/vespalib/util/arrayqueue.hpp> #include <thread> #include <mutex> @@ -11,17 +12,6 @@ namespace fnet { /** - * Interface implemented by objects that want to perform synchronous - * connect initiated by an external thread. - **/ -class ExtConnectable { -protected: - virtual ~ExtConnectable() {} -public: - virtual void ext_connect() = 0; -}; - -/** * An object encapsulating a thread responsible for doing synchronous * external connect. **/ diff --git a/fnet/src/vespa/fnet/connection.h b/fnet/src/vespa/fnet/connection.h index 7b4ba82b90c..16ef66f0cf4 100644 --- a/fnet/src/vespa/fnet/connection.h +++ b/fnet/src/vespa/fnet/connection.h @@ -2,8 +2,7 @@ #pragma once -#include "connect_thread.h" - +#include "ext_connectable.h" /** * Interface implemented by objects that want to perform connection * cleanup. Use the SetCleanupHandler method to register with a diff --git a/fnet/src/vespa/fnet/ext_connectable.h b/fnet/src/vespa/fnet/ext_connectable.h new file mode 100644 index 00000000000..4b1c6e1629c --- /dev/null +++ b/fnet/src/vespa/fnet/ext_connectable.h @@ -0,0 +1,17 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +namespace fnet { +/** + * Interface implemented by objects that want to perform synchronous + * connect initiated by an external thread. + **/ +class ExtConnectable { +protected: + virtual ~ExtConnectable() {} +public: + virtual void ext_connect() = 0; +}; + +} diff --git a/fnet/src/vespa/fnet/transport.cpp b/fnet/src/vespa/fnet/transport.cpp index f82819a49de..2eebc12c150 100644 --- a/fnet/src/vespa/fnet/transport.cpp +++ b/fnet/src/vespa/fnet/transport.cpp @@ -1,8 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/fnet/fnet.h> + +#include "fnet.h" +#include "connect_thread.h" #include <vespa/vespalib/xxhash/xxhash.h> -#include <chrono> namespace { @@ -22,7 +22,7 @@ struct HashState { FNET_Transport::FNET_Transport(size_t num_threads) : _threads(), - _connect_thread() + _connect_thread(std::make_unique<fnet::ConnectThread>()) { assert(num_threads >= 1); for (size_t i = 0; i < num_threads; ++i) { @@ -30,6 +30,12 @@ FNET_Transport::FNET_Transport(size_t num_threads) } } +FNET_Transport::~FNET_Transport() { } + +void FNET_Transport::connect_later(fnet::ExtConnectable *conn) { + _connect_thread->connect_later(conn); +} + FNET_TransportThread * FNET_Transport::select_thread(const void *key, size_t key_len) const { diff --git a/fnet/src/vespa/fnet/transport.h b/fnet/src/vespa/fnet/transport.h index fee94c9d2a5..e3ef3edf4bc 100644 --- a/fnet/src/vespa/fnet/transport.h +++ b/fnet/src/vespa/fnet/transport.h @@ -2,7 +2,12 @@ #pragma once -#include "connect_thread.h" +#include "ext_connectable.h" + +namespace fnet { + class ConnectThread; + class ExtConnectable; +} /** * This class represents the transport layer and handles a collection @@ -16,7 +21,7 @@ private: using Threads = std::vector<Thread>; Threads _threads; - fnet::ConnectThread _connect_thread; + std::unique_ptr<fnet::ConnectThread> _connect_thread; public: /** @@ -27,13 +32,14 @@ public: * be called for single-threaded transports. **/ FNET_Transport(size_t num_threads = 1); + ~FNET_Transport(); /** * Calling this function gives away 1 reference to 'conn' and * ensures that the 'ext_connect' function will be called on it * from another thread some time in the future. **/ - void connect_later(fnet::ExtConnectable *conn) { _connect_thread.connect_later(conn); } + void connect_later(fnet::ExtConnectable *conn); /** * Select one of the underlying transport threads. The selection |