| 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 #include "base/threading/worker_pool.h" | 5 #include "base/threading/worker_pool.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 false); | 77 false); |
| 78 WorkerPool::PostTask(FROM_HERE, | 78 WorkerPool::PostTask(FROM_HERE, |
| 79 base::Bind(&WaitableEvent::Signal, | 79 base::Bind(&WaitableEvent::Signal, |
| 80 base::Unretained(&long_test_event)), | 80 base::Unretained(&long_test_event)), |
| 81 true); | 81 true); |
| 82 | 82 |
| 83 test_event.Wait(); | 83 test_event.Wait(); |
| 84 long_test_event.Wait(); | 84 long_test_event.Wait(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 #if defined(OS_WIN) || defined(OS_LINUX) | 87 #if defined(OS_LINUX) |
| 88 // Flaky on Windows and Linux (http://crbug.com/130337) | 88 // Flaky on Windows and Linux (http://crbug.com/130337) |
| 89 #define MAYBE_PostTaskAndReply DISABLED_PostTaskAndReply | 89 #define MAYBE_PostTaskAndReply DISABLED_PostTaskAndReply |
| 90 #else | 90 #else |
| 91 #define MAYBE_PostTaskAndReply PostTaskAndReply | 91 #define MAYBE_PostTaskAndReply PostTaskAndReply |
| 92 #endif | 92 #endif |
| 93 | 93 |
| 94 TEST_F(WorkerPoolTest, MAYBE_PostTaskAndReply) { | 94 TEST_F(WorkerPoolTest, MAYBE_PostTaskAndReply) { |
| 95 MessageLoop message_loop; | 95 MessageLoop message_loop; |
| 96 scoped_refptr<PostTaskAndReplyTester> tester(new PostTaskAndReplyTester()); | 96 scoped_refptr<PostTaskAndReplyTester> tester(new PostTaskAndReplyTester()); |
| 97 tester->RunTest(); | 97 tester->RunTest(); |
| 98 | 98 |
| 99 const TimeDelta kMaxDuration = TestTimeouts::tiny_timeout(); | 99 const TimeDelta kMaxDuration = TestTimeouts::tiny_timeout(); |
| 100 TimeTicks start = TimeTicks::Now(); | 100 TimeTicks start = TimeTicks::Now(); |
| 101 while (!tester->finished() && TimeTicks::Now() - start < kMaxDuration) { | 101 while (!tester->finished() && TimeTicks::Now() - start < kMaxDuration) { |
| 102 #if defined(OS_IOS) | 102 #if defined(OS_IOS) |
| 103 // Ensure that the other thread has a chance to run even on a single-core | 103 // Ensure that the other thread has a chance to run even on a single-core |
| 104 // device. | 104 // device. |
| 105 pthread_yield_np(); | 105 pthread_yield_np(); |
| 106 #endif | 106 #endif |
| 107 RunLoop().RunUntilIdle(); | 107 RunLoop().RunUntilIdle(); |
| 108 } | 108 } |
| 109 EXPECT_TRUE(tester->finished()); | 109 EXPECT_TRUE(tester->finished()); |
| 110 } | 110 } |
| 111 | 111 |
| 112 } // namespace base | 112 } // namespace base |
| OLD | NEW |