From 592ba4df9885c4b0fc9ab1e74e36cf28c3026f2f Mon Sep 17 00:00:00 2001 From: Mislav Bradac Date: Mon, 26 Jun 2017 18:43:07 +0200 Subject: [PATCH] Minor cleanup Reviewers: buda Reviewed By: buda Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D513 --- src/database/graph_db.hpp | 3 ++ src/dbms/dbms.cpp | 2 +- src/threading/task.hpp | 65 --------------------------------------- 3 files changed, 4 insertions(+), 66 deletions(-) delete mode 100644 src/threading/task.hpp diff --git a/src/database/graph_db.hpp b/src/database/graph_db.hpp index def0bd406..042f8d45c 100644 --- a/src/database/graph_db.hpp +++ b/src/database/graph_db.hpp @@ -52,6 +52,9 @@ class GraphDb { * Database object can't be copied. */ GraphDb(const GraphDb &db) = delete; + GraphDb(GraphDb &&other) = default; + GraphDb &operator=(const GraphDb &other) = default; + GraphDb &operator=(GraphDb &&other) = default; /** * Starts database snapshooting. diff --git a/src/dbms/dbms.cpp b/src/dbms/dbms.cpp index 86853d563..ab8f4a326 100644 --- a/src/dbms/dbms.cpp +++ b/src/dbms/dbms.cpp @@ -24,6 +24,6 @@ std::unique_ptr Dbms::active(const std::string &name, // set and return active db auto &db = it->second; - active_db.store(&db, std::memory_order_release); + active_db.store(&db); return std::make_unique(db); } diff --git a/src/threading/task.hpp b/src/threading/task.hpp deleted file mode 100644 index 1a00f27cf..000000000 --- a/src/threading/task.hpp +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once - -#include - -#include "io/uv/uvloop.hpp" -#include "pool.hpp" -#include "utils/placeholder.hpp" - -class Task { - template - using work_t = std::function; - - template - using after_work_t = std::function; - - template - struct Work { - Work(work_t work, after_work_t after_work) - : work(std::move(work)), after_work(std::move(after_work)) { - req.data = static_cast(this); - } - - void operator()() { result.set(std::move(work())); } - - work_t work; - after_work_t after_work; - - Placeholder result; - - uv_work_t req; - - static void work_cb(uv_work_t* req) { - auto& work = *static_cast*>(req->data); - work(); - } - - static void after_work_cb(uv_work_t* req, int) { - auto work = static_cast*>(req->data); - - work->after_work(std::move(work->result.get())); - - delete work; - } - }; - - public: - using sptr = std::shared_ptr; - - Task(uv::UvLoop::sptr loop) : loop(loop) {} - - Task(Task&) = delete; - Task(Task&&) = delete; - - template - void run(F1&& work, F2&& after_work) { - using T = decltype(work()); - - auto w = new Work(std::forward(work), std::forward(after_work)); - - uv_queue_work(*loop, &w->req, Work::work_cb, Work::after_work_cb); - } - - private: - uv::UvLoop::sptr loop; -};