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

Unified Diff: base/threading/simple_thread.h

Issue 1784623005: Test dynamic priorities (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « base/threading/platform_thread_posix.cc ('k') | base/threading/simple_thread.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/simple_thread.h
diff --git a/base/threading/simple_thread.h b/base/threading/simple_thread.h
index 3deeb1018cb573c3f5e48d2b17b7c16a428aa476..e45ba06ce98b2c4e9701347ac8fc7435fada0b81 100644
--- a/base/threading/simple_thread.h
+++ b/base/threading/simple_thread.h
@@ -112,6 +112,9 @@ class BASE_EXPORT SimpleThread : public PlatformThread::Delegate {
// Overridden from PlatformThread::Delegate:
void ThreadMain() override;
+ bool SetThreadPriority(ThreadPriority priority);
+ ThreadPriority GetThreadPriority() { return priority_; }
+
private:
const std::string name_prefix_;
std::string name_;
@@ -120,6 +123,36 @@ class BASE_EXPORT SimpleThread : public PlatformThread::Delegate {
WaitableEvent event_; // Signaled if Start() was ever called.
PlatformThreadId tid_; // The backing thread's id.
bool joined_; // True if Join has been called.
+ ThreadPriority priority_;
+};
+
+class BASE_EXPORT TestSimpleThread : public SimpleThread {
+ public:
+ struct BASE_EXPORT PrioritySet {
+ explicit PrioritySet(const ThreadPriority d,
+ const ThreadPriority l,
+ const ThreadPriority h)
+ : default_prio(d), low_prio(l), high_prio(h) {}
+ const ThreadPriority default_prio;
+ const ThreadPriority low_prio;
+ const ThreadPriority high_prio;
+ };
+
+ TestSimpleThread(const PrioritySet& priorities,
+ const std::string& name_prefix,
+ const Options& options);
+ bool Speedup();
+ bool Slowdown();
+ bool Restore();
+ bool IsDynamic() { return dynamic_prio_; }
+ ThreadPriority GetDefaultPriority() { return priorities_.default_prio; }
+ std::string GetPrioritySetForDebugging();
+
+ private:
+ const PrioritySet priorities_;
+ bool dynamic_prio_;
+ bool changed_;
+ std::string priorities_str_;
};
class BASE_EXPORT DelegateSimpleThread : public SimpleThread {
« no previous file with comments | « base/threading/platform_thread_posix.cc ('k') | base/threading/simple_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698