OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/task_scheduler/task_scheduler_impl.h" | 5 #include "base/task_scheduler/task_scheduler_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 scheduler_->GetMaxConcurrentTasksWithTraitsDeprecated( | 315 scheduler_->GetMaxConcurrentTasksWithTraitsDeprecated( |
316 TaskTraits().WithPriority(TaskPriority::USER_VISIBLE).MayBlock())); | 316 TaskTraits().WithPriority(TaskPriority::USER_VISIBLE).MayBlock())); |
317 EXPECT_EQ(4, scheduler_->GetMaxConcurrentTasksWithTraitsDeprecated( | 317 EXPECT_EQ(4, scheduler_->GetMaxConcurrentTasksWithTraitsDeprecated( |
318 TaskTraits().WithPriority(TaskPriority::USER_BLOCKING))); | 318 TaskTraits().WithPriority(TaskPriority::USER_BLOCKING))); |
319 EXPECT_EQ( | 319 EXPECT_EQ( |
320 12, | 320 12, |
321 scheduler_->GetMaxConcurrentTasksWithTraitsDeprecated( | 321 scheduler_->GetMaxConcurrentTasksWithTraitsDeprecated( |
322 TaskTraits().WithPriority(TaskPriority::USER_BLOCKING).MayBlock())); | 322 TaskTraits().WithPriority(TaskPriority::USER_BLOCKING).MayBlock())); |
323 } | 323 } |
324 | 324 |
325 // Verify that the RunsTasksOnCurrentThread() method of a Sequenced TaskRunner | |
326 // returns false when called from a task that isn't part of the sequence. Note: | |
gab
2017/02/21 21:39:50
"Note:" ?
robliao
2017/02/22 01:04:19
Removed. (It's no longer needed)
| |
327 TEST_F(TaskSchedulerImplTest, SequencedRunsTasksOnCurrentThread) { | |
328 auto task_runner = | |
329 scheduler_->CreateSingleThreadTaskRunnerWithTraits(TaskTraits()); | |
330 auto sequenced_task_runner = | |
331 scheduler_->CreateSequencedTaskRunnerWithTraits(TaskTraits()); | |
332 | |
333 WaitableEvent task_ran(WaitableEvent::ResetPolicy::MANUAL, | |
334 WaitableEvent::InitialState::NOT_SIGNALED); | |
335 task_runner->PostTask( | |
336 FROM_HERE, | |
337 Bind( | |
338 [](scoped_refptr<TaskRunner> sequenced_task_runner, | |
339 WaitableEvent* task_ran) { | |
340 EXPECT_FALSE(sequenced_task_runner->RunsTasksOnCurrentThread()); | |
341 task_ran->Signal(); | |
342 }, | |
343 sequenced_task_runner, Unretained(&task_ran))); | |
344 task_ran.Wait(); | |
gab
2017/02/21 21:39:50
Also test the other way around?
And drop TaskSche
robliao
2017/02/22 01:04:19
Removed redundant test and added reverse.
| |
345 } | |
346 | |
325 } // namespace internal | 347 } // namespace internal |
326 } // namespace base | 348 } // namespace base |
OLD | NEW |