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.
|
} |
} |