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

Unified Diff: runtime/platform/thread.h

Issue 25909002: Sampling profiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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: runtime/platform/thread.h
diff --git a/runtime/platform/thread.h b/runtime/platform/thread.h
index 4b19f8b5286755b6274632be6481624b898e639b..9acc54041e834853441612397dabee7e60135696 100644
--- a/runtime/platform/thread.h
+++ b/runtime/platform/thread.h
@@ -40,6 +40,8 @@ class Thread {
}
static void SetThreadLocal(ThreadLocalKey key, uword value);
static intptr_t GetMaxStackSize();
+ static ThreadId GetCurrentThreadId();
+ static void GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage);
};
@@ -76,6 +78,7 @@ class Monitor {
// Wait for notification or timeout.
WaitResult Wait(int64_t millis);
+ WaitResult WaitMicros(int64_t micros);
// Notify waiting threads.
void Notify();
@@ -87,6 +90,59 @@ class Monitor {
DISALLOW_COPY_AND_ASSIGN(Monitor);
};
+
+class ScopedMutexLock {
siva 2013/11/11 03:51:54 Should we just call this ScopedMutex ?
Cutch 2013/11/18 20:48:54 Done.
+ public:
+ explicit ScopedMutexLock(Mutex* mutex) : mutex_(mutex) {
+ ASSERT(mutex_ != NULL);
+ mutex_->Lock();
+ }
+
+ ~ScopedMutexLock() {
+ mutex_->Unlock();
+ }
+
+ private:
+ Mutex* const mutex_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedMutexLock);
+};
+
+
+class ScopedMonitorLock {
siva 2013/11/11 03:51:54 Ditto about calling this ScopedMonitor...
Cutch 2013/11/18 20:48:54 Done.
+ public:
+ explicit ScopedMonitorLock(Monitor* monitor) : monitor_(monitor) {
+ ASSERT(monitor_ != NULL);
+ monitor_->Enter();
+ }
+
+ ~ScopedMonitorLock() {
+ monitor_->Exit();
+ }
+
+ Monitor::WaitResult Wait(int64_t millis = dart::Monitor::kNoTimeout) {
+ return monitor_->Wait(millis);
+ }
+
+ Monitor::WaitResult WaitMicros(int64_t micros = dart::Monitor::kNoTimeout) {
+ return monitor_->WaitMicros(micros);
+ }
+
+ void Notify() {
+ monitor_->Notify();
+ }
+
+ void NotifyAll() {
+ monitor_->NotifyAll();
+ }
+
+ private:
+ Monitor* const monitor_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedMonitorLock);
+};
+
+
} // namespace dart

Powered by Google App Engine
This is Rietveld 408576698