diff --git a/src/uvw/resource.hpp b/src/uvw/resource.hpp index dda714c3..fb8c6544 100644 --- a/src/uvw/resource.hpp +++ b/src/uvw/resource.hpp @@ -26,7 +26,7 @@ protected: public: using Callback = std::function; - virtual ~Resource() = 0; + virtual ~Resource() { static_assert(std::is_base_of, T>::value, "!"); } Resource(const Resource &) = delete; Resource(Resource &&) = delete; @@ -51,10 +51,5 @@ private: Callback callback; }; -template -Resource::~Resource() { - static_assert(std::is_base_of, T>::value, "!"); -} - } diff --git a/src/uvw/stream.hpp b/src/uvw/stream.hpp index 02d48f1f..d889dd3b 100644 --- a/src/uvw/stream.hpp +++ b/src/uvw/stream.hpp @@ -7,12 +7,44 @@ namespace uvw { template class Connection: public Resource { using Resource::Resource; + +public: + // TODO read + // TODO stop + // TODO write + // TODO tryWrite }; template class Stream: public Connection { using Connection::Connection; + + static void protoListen(uv_stream_t* srv, int status) { + // TODO + } + +protected: + template + explicit Stream(U *u) + : Connection{u}, + handle{reinterpret_cast(u)} + { } + +public: + // TODO shutdown + // TODO listen + + bool readable() const noexcept { + return (uv_is_readable(handle) == 1); + } + + bool writable() const noexcept { + return (uv_is_writable(handle) == 1); + } + +private: + uv_stream_t *handle; }; diff --git a/src/uvw/tcp.hpp b/src/uvw/tcp.hpp index 6da6867e..e19d7488 100644 --- a/src/uvw/tcp.hpp +++ b/src/uvw/tcp.hpp @@ -33,11 +33,11 @@ public: close([](UVWError){}); } - bool noDelay(bool value = false) { + bool noDelay(bool value = false) noexcept { return (uv_tcp_nodelay(&handle, value ? 1 : 0) == 0); } - bool keepAlive(bool enable = false, Time time = Time{0}) { + bool keepAlive(bool enable = false, Time time = Time{0}) noexcept { return (uv_tcp_keepalive(&handle, enable ? 1 : 0, time.count()) == 0); }