From ef4f12469a33acc204bddf76dac4468fce6d349d Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 18 Jun 2015 13:56:35 +0200 Subject: [PATCH] sleep_for instead of yield reduces the cpu load. --- juci/source.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/juci/source.cc b/juci/source.cc index a57da0f..d981e32 100644 --- a/juci/source.cc +++ b/juci/source.cc @@ -362,7 +362,8 @@ void Source::Controller::OnOpenFile(const string &filepath) { parse_thread=std::thread([this]() { while(true) { - while(!parse_thread_go && !parse_thread_stop) std::this_thread::yield(); + while(!parse_thread_go && !parse_thread_stop) + std::this_thread::sleep_for(std::chrono::milliseconds(10)); if(parse_thread_stop) break; if(!parse_thread_mapped) {