Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: Source/platform/scheduler/TracedTask.cpp

Issue 595023002: Implement idle task scheduling. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/platform/scheduler/TracedTask.cpp
diff --git a/Source/platform/scheduler/TracedTask.cpp b/Source/platform/scheduler/TracedTask.cpp
index d4e1fa69f78c4535379dfbff2f49e00138acad4f..3cbed4ca998a559b1405170f040dddac126dc782 100644
--- a/Source/platform/scheduler/TracedTask.cpp
+++ b/Source/platform/scheduler/TracedTask.cpp
@@ -4,37 +4,68 @@
#include "config.h"
#include "platform/scheduler/TracedTask.h"
+#include "platform/scheduler/Scheduler.h"
namespace blink {
volatile int TracedTask::s_nextFlowTraceID = 0;
-void TracedTask::run() const
+TracedTask::TracedTask(const TraceLocation& location, const char* traceName)
+ : m_location(location)
+ , m_traceName(traceName)
+{
+ bool tracingEnabled;
+ TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink", &tracingEnabled);
+
+ if (tracingEnabled) {
+ // atomicIncrement is slow so we only do it if tracing is enabled
+ m_flowTraceID = static_cast<uint64_t>(atomicIncrement(&s_nextFlowTraceID));
+
+ TRACE_EVENT_FLOW_BEGIN2("blink", m_traceName, MANGLE(m_flowTraceID),
+ "src_file", m_location.fileName(),
+ "src_func", m_location.functionName());
+ }
+}
+
+TracedTask::~TracedTask() { }
+
+void TracedTask::traceRun() const
{
TRACE_EVENT_FLOW_END0("blink", m_traceName, MANGLE(m_flowTraceID));
TRACE_EVENT2("blink", m_traceName,
"src_file", m_location.fileName(),
"src_func", m_location.functionName());
picksi1 2014/09/25 08:53:31 This function is confusingly named, how about upda
rmcilroy 2014/09/29 17:42:58 Changed to endFlowTraceEvent() (and only deals wit
+}
+
+TracedStandardTask::TracedStandardTask(const Task& task, const TraceLocation& location, const char* traceName)
+ : TracedTask(location, traceName)
+ , m_task(task) { }
+TracedStandardTask::~TracedStandardTask() { }
+
+void TracedStandardTask::run() const
+{
+ traceRun();
m_task();
}
-TracedTask::TracedTask(const Task& task, const TraceLocation& location, const char* traceName)
- : m_task(task)
- , m_location(location)
- , m_traceName(traceName)
+TracedIdleTask::TracedIdleTask(const IdleTask& idleTask, const TraceLocation& location, const char* traceName)
+ : TracedTask(location, traceName)
+ , m_idleTask(idleTask)
{
- bool tracingEnabled;
- TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink", &tracingEnabled);
+ ASSERT(Scheduler::shared());
+}
picksi1 2014/09/25 08:53:31 Do we need this ASSERT here? Might there be a situ
rmcilroy 2014/09/29 17:42:57 I think these should only be created by the Schedu
- if (tracingEnabled) {
- // atomicIncrement is slow so we only do it if tracing is enabled
- m_flowTraceID = static_cast<uint64_t>(atomicIncrement(&s_nextFlowTraceID));
+TracedIdleTask::~TracedIdleTask() { }
- TRACE_EVENT_FLOW_BEGIN2("blink", m_traceName, MANGLE(m_flowTraceID),
- "src_file", m_location.fileName(),
- "src_func", m_location.functionName());
+void TracedIdleTask::run() const
+{
+ Scheduler* scheduler = Scheduler::shared();
Sami 2014/09/24 14:00:40 Another note to self: we should keep |scheduler| a
rmcilroy 2014/09/29 17:42:58 Acknowledged.
+ double availableIdleTime = scheduler->getSecondsUntilFrameDeadline();
rmcilroy 2014/09/24 08:49:18 Simon: I'm not entirely convinced that it is worth
picksi1 2014/09/25 08:53:31 I see what you mean. I wonder if there's the begin
rmcilroy 2014/09/29 17:42:57 The fact that the new patch set passes a deadline
+ if (availableIdleTime > 0) {
Sami 2014/09/24 14:00:40 I think there's a race here where the scheduler ca
rmcilroy 2014/09/29 17:42:58 Your right - in the maybeExecuteIdleTask function
+ traceRun();
+ m_idleTask(availableIdleTime * 1000);
picksi1 2014/09/25 08:53:31 Are we able to choose a time unit, seconds or mill
rmcilroy 2014/09/29 17:42:57 Change all APIs to seconds.
}
}

Powered by Google App Engine
This is Rietveld 408576698