diff --git a/src/uvw/loop.hpp b/src/uvw/loop.hpp index 8e0bad1e..000396e7 100644 --- a/src/uvw/loop.hpp +++ b/src/uvw/loop.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "emitter.hpp" #include "util.hpp" @@ -35,6 +36,12 @@ class Loop final: public Emitter, public std::enable_shared_from_this { + BLOCK_SIGNAL = UV_LOOP_BLOCK_SIGNAL + }; + static std::shared_ptr create() { auto ptr = std::unique_ptr{new uv_loop_t, [](uv_loop_t *l){ delete l; }}; auto loop = std::shared_ptr(new Loop{std::move(ptr)}); @@ -77,6 +84,12 @@ public: } } + template + void configure(Configure flag, Args... args) { + auto err = uv_loop_configure(loop.get(), static_cast>(flag), std::forward(args)...); + if(err) { publish(ErrorEvent{err}); } + } + template std::enable_if_t::value, std::shared_ptr> resource(Args&&... args) { @@ -116,6 +129,22 @@ public: uv_stop(loop.get()); } + FileDescriptor descriptor() const noexcept { + return uv_backend_fd(loop.get()); + } + + Time timeout() const noexcept { + return Time{uv_backend_timeout(loop.get())}; + } + + Time now() const noexcept { + return Time{uv_now(loop.get())}; + } + + void update() const noexcept { + return uv_update_time(loop.get()); + } + void walk(std::function callback) { // remember: non-capturing lambdas decay to pointers to functions uv_walk(loop.get(), [](uv_handle_t *handle, void *func) { diff --git a/test/uvw/loop.cpp b/test/uvw/loop.cpp index e94afc02..1dce00c5 100644 --- a/test/uvw/loop.cpp +++ b/test/uvw/loop.cpp @@ -3,6 +3,8 @@ TEST(Loop, Basics) { + // TODO partially done + auto def = uvw::Loop::getDefault(); ASSERT_TRUE(static_cast(def));