summaryrefslogtreecommitdiff
path: root/platform/node/src/util/async_queue.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/node/src/util/async_queue.hpp')
-rw-r--r--platform/node/src/util/async_queue.hpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/platform/node/src/util/async_queue.hpp b/platform/node/src/util/async_queue.hpp
index e9d9e23626..adf40e3ff5 100644
--- a/platform/node/src/util/async_queue.hpp
+++ b/platform/node/src/util/async_queue.hpp
@@ -2,11 +2,12 @@
#include <uv.h>
-#include <thread>
-#include <mutex>
#include <functional>
+#include <mutex>
#include <queue>
#include <string>
+#include <thread>
+#include <utility>
namespace node_mbgl {
namespace util {
@@ -14,8 +15,7 @@ namespace util {
template <typename T>
class AsyncQueue {
public:
- AsyncQueue(uv_loop_t *loop, std::function<void(T &)> fn) :
- callback(fn) {
+ AsyncQueue(uv_loop_t *loop, std::function<void(T &)> fn) : callback(std::move(fn)) {
async.data = this;
uv_async_init(loop, &async, [](uv_async_t* handle) {
auto q = reinterpret_cast<AsyncQueue *>(handle->data);
@@ -41,18 +41,13 @@ public:
}
void stop() {
- uv_close((uv_handle_t *)&async, [](uv_handle_t *handle) {
- delete reinterpret_cast<AsyncQueue *>(handle->data);
- });
+ uv_close(reinterpret_cast<uv_handle_t *>(&async),
+ [](uv_handle_t *handle) { delete reinterpret_cast<AsyncQueue *>(handle->data); });
}
- void ref() {
- uv_ref((uv_handle_t *)&async);
- }
+ void ref() { uv_ref(reinterpret_cast<uv_handle_t *>(&async)); }
- void unref() {
- uv_unref((uv_handle_t *)&async);
- }
+ void unref() { uv_unref(reinterpret_cast<uv_handle_t *>(&async)); }
private:
void process() {
@@ -77,5 +72,5 @@ private:
std::function<void(T &)> callback;
};
-}
-}
+} // namespace util
+} // namespace node_mbgl