From a656ba3343119c0bb795337f7657ae5ac271a245 Mon Sep 17 00:00:00 2001 From: florijan Date: Thu, 17 Aug 2017 09:19:58 +0200 Subject: [PATCH] Scheduler - removed templatization Summary: Because it was unnecessary and also implemented wrong (if someone tried using a Schduler with something other then std::mutex, it would not compile). We can trivially add this if it ever becomes necessary. Reviewers: buda, mislav.bradac Reviewed By: buda, mislav.bradac Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D666 --- src/database/graph_db.hpp | 6 +++--- src/utils/executioner.hpp | 2 +- src/utils/scheduler.hpp | 3 +-- tests/unit/scheduler.cpp | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/database/graph_db.hpp b/src/database/graph_db.hpp index a5515935c..6e2e8452f 100644 --- a/src/database/graph_db.hpp +++ b/src/database/graph_db.hpp @@ -115,9 +115,9 @@ class GraphDb { Snapshooter snapshooter_; // Schedulers - Scheduler gc_scheduler_; - Scheduler snapshot_creator_; + Scheduler gc_scheduler_; + Scheduler snapshot_creator_; // Periodically wakes up and hints to transactions that are running for a long // time to stop their execution. - Scheduler transaction_killer_; + Scheduler transaction_killer_; }; diff --git a/src/utils/executioner.hpp b/src/utils/executioner.hpp index f6e54487e..97d10ed99 100644 --- a/src/utils/executioner.hpp +++ b/src/utils/executioner.hpp @@ -84,6 +84,6 @@ class Executioner { int64_t count_{0}; std::mutex execute_mutex_; std::mutex update_mutex_; - Scheduler scheduler_; + Scheduler scheduler_; std::vector>> id_job_pairs_; }; diff --git a/src/utils/scheduler.hpp b/src/utils/scheduler.hpp index 9a3447d05..eb818677e 100644 --- a/src/utils/scheduler.hpp +++ b/src/utils/scheduler.hpp @@ -13,7 +13,6 @@ * mutex class TMutex which is used to synchronize threads. Default template * value is std::mutex. */ -template class Scheduler { public: Scheduler() {} @@ -74,7 +73,7 @@ class Scheduler { /** * Mutex used to synchronize threads using condition variable. */ - TMutex mutex_; + std::mutex mutex_; /** * Condition variable is used to stop waiting until the end of the diff --git a/tests/unit/scheduler.cpp b/tests/unit/scheduler.cpp index 3c879b85d..bc4a4330b 100644 --- a/tests/unit/scheduler.cpp +++ b/tests/unit/scheduler.cpp @@ -15,7 +15,7 @@ TEST(Scheduler, TestFunctionExecuting) { EXPECT_EQ(y.load(), x.load()); x++; }}; - Scheduler<> scheduler; + Scheduler scheduler; scheduler.Run(std::chrono::seconds(1), func); std::this_thread::sleep_for(std::chrono::milliseconds(980));