From 018642659dced891e3c5769ba2abf1ccce7a9eaa Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Tue, 9 Oct 2018 23:42:03 +0200 Subject: [PATCH] Fixed some new code smells --- include/fc/thread/parallel.hpp | 2 +- include/fc/thread/thread.hpp | 2 ++ src/asio.cpp | 2 +- src/thread/parallel.cpp | 6 +++--- src/thread/thread_d.hpp | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/fc/thread/parallel.hpp b/include/fc/thread/parallel.hpp index 3118703..e9311ab 100644 --- a/include/fc/thread/parallel.hpp +++ b/include/fc/thread/parallel.hpp @@ -49,7 +49,7 @@ namespace fc { private: class ticket_guard { public: - ticket_guard( boost::atomic*>& latch ); + explicit ticket_guard( boost::atomic*>& latch ); ~ticket_guard(); void wait_for_my_turn(); private: diff --git a/include/fc/thread/thread.hpp b/include/fc/thread/thread.hpp index 931a9fe..282fc30 100644 --- a/include/fc/thread/thread.hpp +++ b/include/fc/thread/thread.hpp @@ -25,6 +25,8 @@ namespace fc { */ class thread_idle_notifier { public: + virtual ~thread_idle_notifier() {} + /** This method is called when the thread is idle. If it returns a * task_base it will be queued and executed immediately. * @return a task to execute, or nullptr diff --git a/src/asio.cpp b/src/asio.cpp index 0716bad..35b2990 100644 --- a/src/asio.cpp +++ b/src/asio.cpp @@ -119,7 +119,7 @@ namespace fc { { // the default was not set by the configuration. Determine a good // number of threads. Minimum of 8, maximum of hardware_concurrency - num_io_threads = std::max( boost::thread::hardware_concurrency(), 8u ); + num_io_threads = std::max( boost::thread::hardware_concurrency(), 8U ); } for( uint16_t i = 0; i < num_io_threads; ++i ) diff --git a/src/thread/parallel.cpp b/src/thread/parallel.cpp index dfa85c3..10b709e 100644 --- a/src/thread/parallel.cpp +++ b/src/thread/parallel.cpp @@ -32,8 +32,6 @@ namespace fc { namespace detail { - class pool_impl; - class idle_notifier_impl : public thread_idle_notifier { public: @@ -49,6 +47,8 @@ namespace fc { is_idle.store( copy.is_idle.load() ); } + virtual ~idle_notifier_impl() {} + virtual task_base* idle(); virtual void busy() { @@ -63,7 +63,7 @@ namespace fc { class pool_impl { public: - pool_impl( const uint16_t num_threads ) + explicit pool_impl( const uint16_t num_threads ) : idle_threads( 2 * num_threads ), waiting_tasks( 200 ) { notifiers.resize( num_threads ); diff --git a/src/thread/thread_d.hpp b/src/thread/thread_d.hpp index d07e3f9..c11403a 100644 --- a/src/thread/thread_d.hpp +++ b/src/thread/thread_d.hpp @@ -19,7 +19,7 @@ namespace fc { namespace detail { class idle_guard { public: - idle_guard( thread_d* t ); + explicit idle_guard( thread_d* t ); ~idle_guard(); private: thread_idle_notifier* notifier;