Skip to content

Commit

Permalink
common: adding config.hpp entry to disable background profiler thread
Browse files Browse the repository at this point in the history
  • Loading branch information
bingmann committed Apr 26, 2016
1 parent 7d49440 commit a16e1ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions thrill/common/config.hpp
Expand Up @@ -31,6 +31,9 @@ static constexpr bool g_debug_mode = !g_ndebug;
//! set false if NDEBUG is set in production mode.
static constexpr bool g_self_verify = g_debug_mode;

//! global flag to enable background profiler thread
static constexpr bool g_profile_thread = true;

//! Finding cache line size is hard - we assume 64 byte.
static constexpr unsigned g_cache_line_size = 64;

Expand Down
17 changes: 11 additions & 6 deletions thrill/common/profile_thread.cpp
Expand Up @@ -13,22 +13,27 @@

#include <thrill/common/profile_thread.hpp>

#include <thrill/common/config.hpp>

namespace thrill {
namespace common {

/******************************************************************************/
// ProfileThread

ProfileThread::ProfileThread() {
thread_ = std::thread(&ProfileThread::Worker, this);
if (common::g_profile_thread)
thread_ = std::thread(&ProfileThread::Worker, this);
}

ProfileThread::~ProfileThread() {
std::unique_lock<std::timed_mutex> lock(mutex_);
terminate_ = true;
cv_.notify_one();
lock.unlock();
thread_.join();
if (common::g_profile_thread) {
std::unique_lock<std::timed_mutex> lock(mutex_);
terminate_ = true;
cv_.notify_one();
lock.unlock();
thread_.join();
}

for (Timer& t : tasks_.container()) {
if (t.own_task)
Expand Down

0 comments on commit a16e1ef

Please sign in to comment.