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

Unified Diff: net/base/prioritized_dispatcher.h

Issue 9924023: Readability review (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Responded to Matt's comments. Created 8 years, 7 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 | « no previous file | net/base/prioritized_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/prioritized_dispatcher.h
diff --git a/net/base/prioritized_dispatcher.h b/net/base/prioritized_dispatcher.h
index 7e59d4e67e1bf505ffe460b044ecc64ec942e060..8a7aa45a356d13402cd60402e8c131dec6669282 100644
--- a/net/base/prioritized_dispatcher.h
+++ b/net/base/prioritized_dispatcher.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef NET_BASE_PRIORITY_DISPATCH_H_
-#define NET_BASE_PRIORITY_DISPATCH_H_
+#ifndef NET_BASE_PRIORITIZED_DISPATCHER_H_
+#define NET_BASE_PRIORITIZED_DISPATCHER_H_
#pragma once
#include <vector>
@@ -18,10 +18,10 @@ namespace net {
// jobs. It never revokes a job once started. The job must call OnJobFinished
// once it finishes in order to dispatch further jobs.
//
-// All operations are O(p) time for p priority levels. The class is fully
-// reentrant: it is safe to execute any method (incl. destructor) from within
-// Job callbacks. However, this class is NOT thread-safe, which is enforced
-// by the underlying non-thread-safe PriorityQueue.
+// This class is NOT thread-safe which is enforced by the underlying
+// non-thread-safe PriorityQueue. All operations are O(p) time for p priority
+// levels. It is safe to execute any method, including destructor, from within
+// Job::Start.
//
class NET_EXPORT_PRIVATE PrioritizedDispatcher {
public:
@@ -29,10 +29,13 @@ class NET_EXPORT_PRIVATE PrioritizedDispatcher {
typedef PriorityQueue<Job*>::Priority Priority;
// Describes the limits for the number of jobs started by the dispatcher.
- // For example, |total_jobs| = 30 and |reserved_slots| = { 5, 10, 5 }
- // allow for at most 30 running jobs in total. If there are already 24 jobs
- // running, then there can be 6 more jobs started of which at most 1 can be
- // at priority 1 or 2, but the rest have to be at 2.
+ // For example, |total_jobs| = 30 and |reserved_slots| = { 0, 5, 10, 5 } allow
+ // for at most 30 running jobs in total. Jobs at priority 0 can't use slots
+ // reserved for higher priorities, so they are limited to 10.
+ // If there are already 24 jobs running, then only 6 more jobs can start. No
+ // jobs at priority 1 or below can start. After one more job starts, no jobs
+ // at priority 2 or below can start, since the remaining 5 slots are reserved
+ // for priority 3 or above.
struct NET_EXPORT_PRIVATE Limits {
Limits(Priority num_priorities, size_t total_jobs);
~Limits();
@@ -50,10 +53,10 @@ class NET_EXPORT_PRIVATE PrioritizedDispatcher {
// deleted after it is dispatched or canceled, or the dispatcher is destroyed.
class Job {
public:
- // Note: PriorityDispatch will never delete a Job.
+ // Note: PrioritizedDispatcher will never delete a Job.
virtual ~Job() {}
- // Called when the dispatcher starts the job. Must call OnJobFinished when
- // done.
+ // Called when the dispatcher starts the job. Once the job finishes, it must
+ // call OnJobFinished.
virtual void Start() = 0;
};
@@ -62,7 +65,7 @@ class NET_EXPORT_PRIVATE PrioritizedDispatcher {
typedef PriorityQueue<Job*>::Pointer Handle;
// Creates a dispatcher enforcing |limits| on number of running jobs.
- PrioritizedDispatcher(const Limits& limits);
+ explicit PrioritizedDispatcher(const Limits& limits);
~PrioritizedDispatcher();
@@ -72,7 +75,8 @@ class NET_EXPORT_PRIVATE PrioritizedDispatcher {
// Adds |job| with |priority| to the dispatcher. If limits permit, |job| is
// started immediately. Returns handle to the job or null-handle if the job is
- // started.
+ // started. The dispatcher does not own |job|, but must |job| must live until
+ // it is started, canceled or evicted.
szym 2012/06/01 18:47:37 Changed to: "The dispatcher does not own |job|, bu
Handle Add(Job* job, Priority priority);
// Removes the job with |handle| from the queue. Invalidates |handle|.
@@ -111,5 +115,4 @@ class NET_EXPORT_PRIVATE PrioritizedDispatcher {
} // namespace net
-#endif // NET_BASE_PRIORITY_DISPATCH_H_
-
+#endif // NET_BASE_PRIORITIZED_DISPATCHER_H_
« no previous file with comments | « no previous file | net/base/prioritized_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698