diff --git a/src/uvw/async.hpp b/src/uvw/async.hpp index 23f4a5e6..a2c17fbc 100644 --- a/src/uvw/async.hpp +++ b/src/uvw/async.hpp @@ -28,7 +28,7 @@ public: return std::shared_ptr{new Async{std::forward(args)...}}; } - bool init() { return initialize(&uv_async_init, sendCallback); } + bool init() { return initialize(&uv_async_init, &sendCallback); } void send() { invoke(&uv_async_send, get()); } }; diff --git a/src/uvw/emitter.hpp b/src/uvw/emitter.hpp index 5c1be7b5..010386c7 100644 --- a/src/uvw/emitter.hpp +++ b/src/uvw/emitter.hpp @@ -33,12 +33,12 @@ class Emitter { return onceL.empty() && onL.empty(); } - Connection once(Listener f) noexcept { + Connection once(Listener f) { auto conn = onceL.insert(onceL.cbegin(), std::move(f)); return { onceL, std::move(conn) }; } - Connection on(Listener f) noexcept { + Connection on(Listener f) { auto conn = onL.insert(onL.cbegin(), std::move(f)); return { onL, std::move(conn) }; } @@ -52,7 +52,7 @@ class Emitter { onL.clear(); } - void publish(const E &event, T &ref) noexcept { + void publish(const E &event, T &ref) { for(auto &&listener: onceL) { listener(event, ref); } for(auto &&listener: onL) { listener(event, ref); } onceL.clear(); @@ -82,7 +82,7 @@ class Emitter { protected: template - void publish(E event) noexcept { + void publish(E event) { handler().publish(event, *static_cast(this)); } @@ -98,17 +98,17 @@ public: template using Listener = typename Handler::Listener; - virtual ~Emitter() { + virtual ~Emitter() noexcept { static_assert(std::is_base_of, T>::value, "!"); } template - Connection on(Listener f) noexcept { + Connection on(Listener f) { return handler().on(std::move(f)); } template - Connection once(Listener f) noexcept { + Connection once(Listener f) { return handler().once(std::move(f)); } diff --git a/src/uvw/event.hpp b/src/uvw/event.hpp index 488c558c..8da95980 100644 --- a/src/uvw/event.hpp +++ b/src/uvw/event.hpp @@ -11,7 +11,7 @@ namespace uvw { struct BaseEvent { - virtual ~BaseEvent() = 0; + virtual ~BaseEvent() noexcept = 0; static std::size_t next() noexcept { static std::size_t cnt = 0; @@ -19,7 +19,7 @@ struct BaseEvent { } }; -BaseEvent::~BaseEvent() { } +BaseEvent::~BaseEvent() noexcept { } template struct Event: BaseEvent { diff --git a/src/uvw/loop.hpp b/src/uvw/loop.hpp index 27daa66e..8e0bad1e 100644 --- a/src/uvw/loop.hpp +++ b/src/uvw/loop.hpp @@ -25,12 +25,14 @@ public: class Loop final: public Emitter, public std::enable_shared_from_this { + using Deleter = void(*)(uv_loop_t *); + template friend class Resource; - using Deleter = std::function; - - Loop(std::unique_ptr ptr): loop{std::move(ptr)} { } + Loop(std::unique_ptr ptr) noexcept + : loop{std::move(ptr)} + { } public: static std::shared_ptr create() { @@ -69,7 +71,7 @@ public: Loop& operator=(const Loop &) = delete; Loop& operator=(Loop &&other) = delete; - ~Loop() { + ~Loop() noexcept { if(loop) { close(); } @@ -89,7 +91,7 @@ public: return R::create(shared_from_this(), std::forward(args)...); } - void close() noexcept { + void close() { auto err = uv_loop_close(loop.get()); if(err) { publish(ErrorEvent{err}); } } @@ -114,7 +116,7 @@ public: uv_stop(loop.get()); } - void walk(std::function callback) noexcept { + void walk(std::function callback) { // remember: non-capturing lambdas decay to pointers to functions uv_walk(loop.get(), [](uv_handle_t *handle, void *func) { BaseHandle &ref = *static_cast(handle->data); diff --git a/src/uvw/request.hpp b/src/uvw/request.hpp index 68faac3b..be798898 100644 --- a/src/uvw/request.hpp +++ b/src/uvw/request.hpp @@ -48,7 +48,7 @@ protected: } public: - void cancel() noexcept { + void cancel() { invoke(&uv_cancel, this->template get()); } diff --git a/src/uvw/signal.hpp b/src/uvw/signal.hpp index 66747061..bcd19cda 100644 --- a/src/uvw/signal.hpp +++ b/src/uvw/signal.hpp @@ -30,7 +30,7 @@ public: bool init() { return initialize(&uv_signal_init); } - void start(int signum) { invoke(uv_signal_start, get(), &startCallback, signum); } + void start(int signum) { invoke(&uv_signal_start, get(), &startCallback, signum); } void stop() { invoke(&uv_signal_stop, get()); } int signal() const noexcept { return get()->signum; } diff --git a/src/uvw/stream.hpp b/src/uvw/stream.hpp index 0e3261ad..6ee3369b 100644 --- a/src/uvw/stream.hpp +++ b/src/uvw/stream.hpp @@ -29,7 +29,7 @@ public: return std::shared_ptr{new Shutdown{std::forward(args)...}}; } - void shutdown(uv_stream_t *handle) noexcept { + void shutdown(uv_stream_t *handle) { exec(&uv_shutdown, get(), handle); } }; @@ -90,7 +90,7 @@ protected: { } public: - void shutdown() noexcept { + void shutdown() { std::weak_ptr weak = this->shared_from_this(); auto listener = [weak](const auto &event, details::Shutdown &) { @@ -104,11 +104,11 @@ public: shutdown->shutdown(this->template get()); } - void listen(int backlog) noexcept { + void listen(int backlog) { this->invoke(&uv_listen, this->template get(), backlog, &listenCallback); } - void listen() noexcept { + void listen() { listen(DEFAULT_BACKLOG); } @@ -116,7 +116,7 @@ public: this->invoke(&uv_read_start, this->template get(), &allocCallback, &readCallback); } - void stop() noexcept { + void stop() { this->invoke(&uv_read_stop, this->template get()); } @@ -139,7 +139,7 @@ public: write(data.get(), length); } - int tryWrite(char *data, ssize_t length) noexcept { + int tryWrite(char *data, ssize_t length) { uv_buf_t bufs[] = { uv_buf_init(data, length) }; auto bw = uv_try_write(this->template get(), bufs, 1); @@ -151,7 +151,7 @@ public: return bw; } - int tryWrite(std::unique_ptr data, ssize_t length) noexcept { + int tryWrite(std::unique_ptr data, ssize_t length) { return tryWrite(data.get(), length); } diff --git a/src/uvw/tcp.hpp b/src/uvw/tcp.hpp index 1f03f117..31743c08 100644 --- a/src/uvw/tcp.hpp +++ b/src/uvw/tcp.hpp @@ -29,7 +29,7 @@ public: return std::shared_ptr{new Connect{std::forward(args)...}}; } - void connect(uv_tcp_t *handle, const sockaddr *addr) noexcept { + void connect(uv_tcp_t *handle, const sockaddr *addr) { exec(&uv_tcp_connect, get(), handle, addr); } }; @@ -81,16 +81,16 @@ public: bool init() { return initialize(&uv_tcp_init); } - void noDelay(bool value = false) noexcept { + void noDelay(bool value = false) { invoke(&uv_tcp_nodelay, get(), value ? 1 : 0); } - void keepAlive(bool enable = false, Time time = Time{0}) noexcept { + void keepAlive(bool enable = false, Time time = Time{0}) { invoke(&uv_tcp_keepalive, get(), enable ? 1 : 0, time.count()); } template> - void bind(std::string ip, unsigned int port, bool ipv6only = false) noexcept { + void bind(std::string ip, unsigned int port, bool ipv6only = false) { typename Traits::Type addr; Traits::AddrFunc(ip.c_str(), port, &addr); unsigned int flags = ipv6only ? UV_TCP_IPV6ONLY : 0; @@ -98,7 +98,7 @@ public: } template> - void bind(Addr addr, bool ipv6only = false) noexcept { + void bind(Addr addr, bool ipv6only = false) { bind(addr.ip, addr.port, ipv6only); } @@ -113,7 +113,7 @@ public: } template> - void connect(std::string ip, unsigned int port) noexcept { + void connect(std::string ip, unsigned int port) { typename Traits::Type addr; Traits::AddrFunc(ip.c_str(), port, &addr); @@ -131,11 +131,11 @@ public: } template> - void connect(Addr addr) noexcept { + void connect(Addr addr) { connect(addr.ip, addr.port); } - void accept(Tcp &tcp) noexcept { + void accept(Tcp &tcp) { invoke(&uv_accept, get(), tcp.get()); } }; diff --git a/src/uvw/timer.hpp b/src/uvw/timer.hpp index c321af80..eaacc9e5 100644 --- a/src/uvw/timer.hpp +++ b/src/uvw/timer.hpp @@ -33,7 +33,7 @@ public: bool init() { return initialize(&uv_timer_init); } - void start(Time timeout, Time repeat) { invoke(uv_timer_start, get(), &startCallback, timeout.count(), repeat.count()); } + void start(Time timeout, Time repeat) { invoke(&uv_timer_start, get(), &startCallback, timeout.count(), repeat.count()); } void stop() { invoke(&uv_timer_stop, get()); } void again() { invoke(&uv_timer_again, get()); } diff --git a/src/uvw/work.hpp b/src/uvw/work.hpp index 421c5a95..19b0fad2 100644 --- a/src/uvw/work.hpp +++ b/src/uvw/work.hpp @@ -30,7 +30,7 @@ public: return std::shared_ptr{new Work{std::forward(args)...}}; } - void queue(Task t) noexcept { + void queue(Task t) { if(0 == exec(&uv_queue_work, parent(), get(), &workCallback)) { task = std::move(t); }