| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Multi-threaded tests of ConditionVariable class. | 5 // Multi-threaded tests of ConditionVariable class. |
| 6 | 6 |
| 7 #include <time.h> | 7 #include <time.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 // Callers are responsible for synchronizing access to the following class. | 61 // Callers are responsible for synchronizing access to the following class. |
| 62 // The WorkQueue::lock_, as accessed via WorkQueue::lock(), should be used for | 62 // The WorkQueue::lock_, as accessed via WorkQueue::lock(), should be used for |
| 63 // all synchronized access. | 63 // all synchronized access. |
| 64 class WorkQueue : public PlatformThread::Delegate { | 64 class WorkQueue : public PlatformThread::Delegate { |
| 65 public: | 65 public: |
| 66 explicit WorkQueue(int thread_count); | 66 explicit WorkQueue(int thread_count); |
| 67 virtual ~WorkQueue(); | 67 virtual ~WorkQueue(); |
| 68 | 68 |
| 69 // PlatformThread::Delegate interface. | 69 // PlatformThread::Delegate interface. |
| 70 virtual void ThreadMain() OVERRIDE; | 70 void ThreadMain() override; |
| 71 | 71 |
| 72 //---------------------------------------------------------------------------- | 72 //---------------------------------------------------------------------------- |
| 73 // Worker threads only call the following methods. | 73 // Worker threads only call the following methods. |
| 74 // They should use the lock to get exclusive access. | 74 // They should use the lock to get exclusive access. |
| 75 int GetThreadId(); // Get an ID assigned to a thread.. | 75 int GetThreadId(); // Get an ID assigned to a thread.. |
| 76 bool EveryIdWasAllocated() const; // Indicates that all IDs were handed out. | 76 bool EveryIdWasAllocated() const; // Indicates that all IDs were handed out. |
| 77 TimeDelta GetAnAssignment(int thread_id); // Get a work task duration. | 77 TimeDelta GetAnAssignment(int thread_id); // Get a work task duration. |
| 78 void WorkIsCompleted(int thread_id); | 78 void WorkIsCompleted(int thread_id); |
| 79 | 79 |
| 80 int task_count() const; | 80 int task_count() const; |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 base::AutoLock auto_lock(lock_); | 754 base::AutoLock auto_lock(lock_); |
| 755 // Send notification that we completed our "work." | 755 // Send notification that we completed our "work." |
| 756 WorkIsCompleted(thread_id); | 756 WorkIsCompleted(thread_id); |
| 757 } | 757 } |
| 758 } | 758 } |
| 759 } | 759 } |
| 760 | 760 |
| 761 } // namespace | 761 } // namespace |
| 762 | 762 |
| 763 } // namespace base | 763 } // namespace base |
| OLD | NEW |