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

Unified Diff: base/task_scheduler/scheduler_worker_stack.h

Issue 2116163002: Add Lazy Creation and Thread Detachment Support in the Scheduler Worker Pool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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: base/task_scheduler/scheduler_worker_stack.h
diff --git a/base/task_scheduler/scheduler_worker_stack.h b/base/task_scheduler/scheduler_worker_stack.h
index 1d1748ca10520a7a39b626268edec3f81a97ff01..649a629e664234a507770d0808f0fc7cf4bc597e 100644
--- a/base/task_scheduler/scheduler_worker_stack.h
+++ b/base/task_scheduler/scheduler_worker_stack.h
@@ -17,11 +17,11 @@ namespace internal {
class SchedulerWorker;
-// A stack of SchedulerWorkers. Supports removal of arbitrary
-// SchedulerWorkers. DCHECKs when a SchedulerWorker is inserted
-// multiple times. SchedulerWorkers are not owned by the stack. Push() is
-// amortized O(1). Pop(), Size() and Empty() are O(1). Remove is O(n). This
-// class is NOT thread-safe.
+// A stack of SchedulerWorkers. Supports removal of arbitrary SchedulerWorkers.
+// DCHECKs when a SchedulerWorker is inserted multiple times. SchedulerWorkers
+// are not owned by the stack. Push() is amortized O(1). Pop(), Peek(), Size()
+// and Empty() are O(1). Contains() and Remove() are O(n).
+// This class is NOT thread-safe.
class BASE_EXPORT SchedulerWorkerStack {
public:
SchedulerWorkerStack();
@@ -35,6 +35,13 @@ class BASE_EXPORT SchedulerWorkerStack {
// Returns nullptr if the stack is empty.
SchedulerWorker* Pop();
+ // Removes the top SchedulerWorker from the stack and returns it.
+ // Returns nullptr if the stack is empty.
+ SchedulerWorker* Peek() const;
+
+ // Returns true if |worker| is already on the stack.
+ bool Contains(const SchedulerWorker* worker) const;
+
// Removes |worker| from the stack.
void Remove(const SchedulerWorker* worker);

Powered by Google App Engine
This is Rietveld 408576698