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

Side by Side Diff: components/drive/job_queue.h

Issue 1546143002: Switch to standard integer types in components/, part 1 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 unified diff | Download patch
« no previous file with comments | « components/drive/job_list.h ('k') | components/drive/job_queue.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_DRIVE_JOB_QUEUE_H_ 5 #ifndef COMPONENTS_DRIVE_JOB_QUEUE_H_
6 #define COMPONENTS_DRIVE_JOB_QUEUE_H_ 6 #define COMPONENTS_DRIVE_JOB_QUEUE_H_
7 7
8 #include <stddef.h>
9 #include <stdint.h>
10
8 #include <deque> 11 #include <deque>
9 #include <set> 12 #include <set>
10 #include <vector> 13 #include <vector>
11 14
15 #include "base/macros.h"
12 #include "components/drive/job_list.h" 16 #include "components/drive/job_list.h"
13 17
14 namespace drive { 18 namespace drive {
15 19
16 // Priority queue for managing jobs in JobScheduler. 20 // Priority queue for managing jobs in JobScheduler.
17 class JobQueue { 21 class JobQueue {
18 public: 22 public:
19 // Creates a queue that allows |num_max_concurrent_jobs| concurrent job 23 // Creates a queue that allows |num_max_concurrent_jobs| concurrent job
20 // execution and has |num_priority_levels| levels of priority. 24 // execution and has |num_priority_levels| levels of priority.
21 JobQueue(size_t num_max_concurrent_jobs, 25 JobQueue(size_t num_max_concurrent_jobs,
22 size_t num_priority_levels, 26 size_t num_priority_levels,
23 size_t num_max_batch_jobs, 27 size_t num_max_batch_jobs,
24 size_t max_batch_size); 28 size_t max_batch_size);
25 ~JobQueue(); 29 ~JobQueue();
26 30
27 // Pushes a job |id| of |priority|. The job with the smallest priority value 31 // Pushes a job |id| of |priority|. The job with the smallest priority value
28 // is popped first (lower values are higher priority). In the same priority, 32 // is popped first (lower values are higher priority). In the same priority,
29 // the queue is "first-in first-out". If multiple jobs with |batchable| = true 33 // the queue is "first-in first-out". If multiple jobs with |batchable| = true
30 // are pushed continuously, there will be popped at the same time unless the 34 // are pushed continuously, there will be popped at the same time unless the
31 // number of jobs exceeds |num_max_batch_jobs_| or the sum of |job_size| 35 // number of jobs exceeds |num_max_batch_jobs_| or the sum of |job_size|
32 // exceeds or |max_batch_size_|. 36 // exceeds or |max_batch_size_|.
33 void Push(JobID id, int priority, bool batchable, uint64 job_size); 37 void Push(JobID id, int priority, bool batchable, uint64_t job_size);
34 38
35 // Pops the first job which meets |accepted_priority| (i.e. the first job in 39 // Pops the first job which meets |accepted_priority| (i.e. the first job in
36 // the queue with equal or higher priority (lower value)), and the limit of 40 // the queue with equal or higher priority (lower value)), and the limit of
37 // concurrent job count is satisfied. 41 // concurrent job count is satisfied.
38 // 42 //
39 // For instance, if |accepted_priority| is 1, the first job with priority 0 43 // For instance, if |accepted_priority| is 1, the first job with priority 0
40 // (higher priority) in the queue is picked even if a job with priority 1 was 44 // (higher priority) in the queue is picked even if a job with priority 1 was
41 // pushed earlier. If there is no job with priority 0, the first job with 45 // pushed earlier. If there is no job with priority 0, the first job with
42 // priority 1 in the queue is picked. 46 // priority 1 in the queue is picked.
43 // 47 //
(...skipping 16 matching lines...) Expand all
60 size_t GetNumberOfJobs() const; 64 size_t GetNumberOfJobs() const;
61 65
62 // Removes the job from the queue. 66 // Removes the job from the queue.
63 void Remove(JobID id); 67 void Remove(JobID id);
64 68
65 private: 69 private:
66 // JobID and additional properties that are needed to determine which tasks it 70 // JobID and additional properties that are needed to determine which tasks it
67 // runs next. 71 // runs next.
68 struct Item { 72 struct Item {
69 Item(); 73 Item();
70 Item(JobID id, bool batchable, uint64 size); 74 Item(JobID id, bool batchable, uint64_t size);
71 ~Item(); 75 ~Item();
72 JobID id; 76 JobID id;
73 bool batchable; 77 bool batchable;
74 uint64 size; 78 uint64_t size;
75 }; 79 };
76 80
77 const size_t num_max_concurrent_jobs_; 81 const size_t num_max_concurrent_jobs_;
78 std::vector<std::deque<Item>> queue_; 82 std::vector<std::deque<Item>> queue_;
79 const size_t num_max_batch_jobs_; 83 const size_t num_max_batch_jobs_;
80 const size_t max_batch_size_; 84 const size_t max_batch_size_;
81 std::set<JobID> running_; 85 std::set<JobID> running_;
82 86
83 DISALLOW_COPY_AND_ASSIGN(JobQueue); 87 DISALLOW_COPY_AND_ASSIGN(JobQueue);
84 }; 88 };
85 89
86 } // namespace drive 90 } // namespace drive
87 91
88 #endif // COMPONENTS_DRIVE_JOB_QUEUE_H_ 92 #endif // COMPONENTS_DRIVE_JOB_QUEUE_H_
OLDNEW
« no previous file with comments | « components/drive/job_list.h ('k') | components/drive/job_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698