OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 shutdown_ = true; | 654 shutdown_ = true; |
655 } | 655 } |
656 | 656 |
657 void WorkQueue::SpinUntilAllThreadsAreWaiting() { | 657 void WorkQueue::SpinUntilAllThreadsAreWaiting() { |
658 while (true) { | 658 while (true) { |
659 { | 659 { |
660 base::AutoLock auto_lock(lock_); | 660 base::AutoLock auto_lock(lock_); |
661 if (waiting_thread_count_ == thread_count_) | 661 if (waiting_thread_count_ == thread_count_) |
662 break; | 662 break; |
663 } | 663 } |
664 PlatformThread::Sleep(30); | 664 PlatformThread::Sleep(TimeDelta::FromMilliseconds(30)); |
665 } | 665 } |
666 } | 666 } |
667 | 667 |
668 void WorkQueue::SpinUntilTaskCountLessThan(int task_count) { | 668 void WorkQueue::SpinUntilTaskCountLessThan(int task_count) { |
669 while (true) { | 669 while (true) { |
670 { | 670 { |
671 base::AutoLock auto_lock(lock_); | 671 base::AutoLock auto_lock(lock_); |
672 if (task_count_ < task_count) | 672 if (task_count_ < task_count) |
673 break; | 673 break; |
674 } | 674 } |
675 PlatformThread::Sleep(30); | 675 PlatformThread::Sleep(TimeDelta::FromMilliseconds(30)); |
676 } | 676 } |
677 } | 677 } |
678 | 678 |
679 | 679 |
680 //------------------------------------------------------------------------------ | 680 //------------------------------------------------------------------------------ |
681 // Define the standard worker task. Several tests will spin out many of these | 681 // Define the standard worker task. Several tests will spin out many of these |
682 // threads. | 682 // threads. |
683 //------------------------------------------------------------------------------ | 683 //------------------------------------------------------------------------------ |
684 | 684 |
685 // The multithread tests involve several threads with a task to perform as | 685 // The multithread tests involve several threads with a task to perform as |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 base::AutoLock auto_lock(lock_); | 741 base::AutoLock auto_lock(lock_); |
742 // Send notification that we completed our "work." | 742 // Send notification that we completed our "work." |
743 WorkIsCompleted(thread_id); | 743 WorkIsCompleted(thread_id); |
744 } | 744 } |
745 } | 745 } |
746 } | 746 } |
747 | 747 |
748 } // namespace | 748 } // namespace |
749 | 749 |
750 } // namespace base | 750 } // namespace base |
OLD | NEW |