From 0c974d4a2c71b09b31da9dc93a0b8b9de59b7cc9 Mon Sep 17 00:00:00 2001 From: ronag Date: Mon, 5 Dec 2011 22:21:23 +0000 Subject: [PATCH] 2.0.2: graph: Fixed bad scheduling. git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.2@1799 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d --- common/diagnostics/graph.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/common/diagnostics/graph.cpp b/common/diagnostics/graph.cpp index 3e40b4dcb..b71606f93 100644 --- a/common/diagnostics/graph.cpp +++ b/common/diagnostics/graph.cpp @@ -58,10 +58,10 @@ class context : public drawable public: template - static void begin_invoke(Func&& func) // noexcept + static void begin_invoke(Func&& func, task_priority priority) // noexcept { - if(get_instance().executor_.size() < 1024) - get_instance().executor_.begin_invoke(std::forward(func)); + if(get_instance().executor_.size() < 128) + get_instance().executor_.begin_invoke(std::forward(func), priority); } static void register_drawable(const std::shared_ptr& drawable) @@ -72,7 +72,7 @@ public: begin_invoke([=] { get_instance().do_register_drawable(drawable); - }); + }, high_priority); } static void show(bool value) @@ -80,7 +80,7 @@ public: begin_invoke([=] { get_instance().do_show(value); - }); + }, high_priority); } private: @@ -250,7 +250,7 @@ public: if(!tick_data_.empty()) { - float sum = *std::max_element(tick_data_.begin(), tick_data_.end()) + std::numeric_limits::min(); + float sum = std::accumulate(tick_data_.begin(), tick_data_.end(), 0.0) + std::numeric_limits::min(); line_data_.push_back(std::make_pair(static_cast(sum)/static_cast(tick_data_.size()), tick_tag_)); tick_data_.clear(); } @@ -391,12 +391,16 @@ void graph::set_text(const std::string& value) context::begin_invoke([=] { p->set_text(value); - }); + }, high_priority); } void graph::set_text(const std::wstring& value) { - set_text(narrow(value)); + auto p = impl_; + context::begin_invoke([=] + { + set_text(narrow(value)); + }, high_priority); } void graph::update_value(const std::string& name, double value) @@ -405,7 +409,7 @@ void graph::update_value(const std::string& name, double value) context::begin_invoke([=] { p->update(name, value); - }); + }, high_priority); } void graph::set_value(const std::string& name, double value) { @@ -413,7 +417,7 @@ void graph::set_value(const std::string& name, double value) context::begin_invoke([=] { p->set(name, value); - }); + }, high_priority); } void graph::set_color(const std::string& name, color c) { @@ -421,7 +425,7 @@ void graph::set_color(const std::string& name, color c) context::begin_invoke([=] { p->set_color(name, c); - }); + }, high_priority); } void graph::add_tag(const std::string& name) { @@ -429,7 +433,7 @@ void graph::add_tag(const std::string& name) context::begin_invoke([=] { p->tag(name); - }); + }, high_priority); } void graph::add_guide(const std::string& name, double value) { @@ -437,7 +441,7 @@ void graph::add_guide(const std::string& name, double value) context::begin_invoke([=] { p->guide(name, value); - }); + }, high_priority); } void register_graph(const safe_ptr& graph) -- 2.39.5