| Index: net/base/prioritized_dispatcher.h
|
| diff --git a/net/base/prioritized_dispatcher.h b/net/base/prioritized_dispatcher.h
|
| index 7e59d4e67e1bf505ffe460b044ecc64ec942e060..cea175773d1dbb10d3971114856067eb2173b45e 100644
|
| --- a/net/base/prioritized_dispatcher.h
|
| +++ b/net/base/prioritized_dispatcher.h
|
| @@ -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,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);
|
|
|
| // 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_
|
|
|
| +
|
|
|