Add clang-format (#1086)

Co-authored-by: mwilsnd <mwilsnd@gmail.com>
This commit is contained in:
Bart Louwers
2023-05-01 16:57:37 +02:00
committed by GitHub
parent 403a12bd1b
commit 71f6da2722
1018 changed files with 27876 additions and 25862 deletions

View File

@@ -12,7 +12,9 @@ namespace util {
class AsyncTask::Impl {
public:
explicit Impl(std::function<void()> fn) : async(new uv_async_t), task(std::move(fn)) {
explicit Impl(std::function<void()> fn)
: async(new uv_async_t),
task(std::move(fn)) {
auto* loop = reinterpret_cast<uv_loop_t*>(RunLoop::getLoopHandle());
if (uv_async_init(loop, async, asyncCallback) != 0) {
throw std::runtime_error("Failed to initialize async.");
@@ -23,9 +25,7 @@ public:
}
~Impl() {
uv_close(handle(), [](uv_handle_t* h) {
delete reinterpret_cast<uv_async_t*>(h);
});
uv_close(handle(), [](uv_handle_t* h) { delete reinterpret_cast<uv_async_t*>(h); });
}
void maySend() {
@@ -36,13 +36,9 @@ public:
}
private:
static void asyncCallback(uv_async_t* handle) {
reinterpret_cast<Impl*>(handle->data)->task();
}
static void asyncCallback(uv_async_t* handle) { reinterpret_cast<Impl*>(handle->data)->task(); }
uv_handle_t* handle() {
return reinterpret_cast<uv_handle_t*>(async);
}
uv_handle_t* handle() { return reinterpret_cast<uv_handle_t*>(async); }
uv_async_t* async;
@@ -50,8 +46,7 @@ private:
};
AsyncTask::AsyncTask(std::function<void()>&& fn)
: impl(std::make_unique<Impl>(std::move(fn))) {
}
: impl(std::make_unique<Impl>(std::move(fn))) {}
AsyncTask::~AsyncTask() = default;