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

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 review. 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..fa50019da086c9748f3a12288132c42c61ded8d9 100644
--- a/net/base/prioritized_dispatcher.h
+++ b/net/base/prioritized_dispatcher.h
@@ -20,7 +20,7 @@ namespace net {
//
// 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
stevez 2012/05/17 17:57:07 Ok, let me be more clear: can you provide an exam
szym 2012/05/17 19:52:01 Understood. I should remove "re-entrant" and leave
-// Job callbacks. However, this class is NOT thread-safe, which is enforced
+// Job::Start. However, this class is NOT thread-safe, which is enforced
// by the underlying non-thread-safe PriorityQueue.
//
class NET_EXPORT_PRIVATE PrioritizedDispatcher {
@@ -29,10 +29,11 @@ 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 }
+ // For example, |total_jobs| = 30 and |reserved_slots| = { 0, 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.
+ // 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 +51,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 +63,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 +73,7 @@ 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 be outlived by |job|.
Handle Add(Job* job, Priority priority);
stevez 2012/05/17 17:57:07 parameter ordering still needs to be fixed
szym 2012/05/17 19:52:01 I see the second part of my comment does not show
stevez 2012/05/22 14:22:40 Ok on the parameter order, but can you explain wha
szym 2012/05/23 01:26:49 PrioritizedDispatcher::Job has only one method, so
stevez 2012/05/30 17:12:45 Does chromium use a different callback library tha
szym 2012/05/30 23:53:24 Yes, Chromium uses different callback library. If
// Removes the job with |handle| from the queue. Invalidates |handle|.
@@ -113,3 +114,4 @@ class NET_EXPORT_PRIVATE PrioritizedDispatcher {
#endif // NET_BASE_PRIORITY_DISPATCH_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