OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 std::cout << "End time is " << GetCurrentTime() << std::endl; | 209 std::cout << "End time is " << GetCurrentTime() << std::endl; |
210 } | 210 } |
211 | 211 |
212 void OnTimeoutStuck(const int id) { | 212 void OnTimeoutStuck(const int id) { |
213 LOG(LS_INFO) << "Timed out task " << id; | 213 LOG(LS_INFO) << "Timed out task " << id; |
214 | 214 |
215 int i; | 215 int i; |
216 for (i = 0; i < STUCK_TASK_COUNT; ++i) { | 216 for (i = 0; i < STUCK_TASK_COUNT; ++i) { |
217 if (stuck_[i].xlat_ == id) { | 217 if (stuck_[i].xlat_ == id) { |
218 stuck_[i].timed_out_ = true; | 218 stuck_[i].timed_out_ = true; |
219 stuck_[i].task_ = NULL; | 219 stuck_[i].task_ = nullptr; |
220 break; | 220 break; |
221 } | 221 } |
222 } | 222 } |
223 | 223 |
224 // getting a bad ID here is a failure, but let's continue | 224 // getting a bad ID here is a failure, but let's continue |
225 // running to see what else might go wrong | 225 // running to see what else might go wrong |
226 EXPECT_LT(i, STUCK_TASK_COUNT); | 226 EXPECT_LT(i, STUCK_TASK_COUNT); |
227 } | 227 } |
228 | 228 |
229 void OnTimeoutHappy(const int id) { | 229 void OnTimeoutHappy(const int id) { |
230 int i; | 230 int i; |
231 for (i = 0; i < HAPPY_TASK_COUNT; ++i) { | 231 for (i = 0; i < HAPPY_TASK_COUNT; ++i) { |
232 if (happy_[i].xlat_ == id) { | 232 if (happy_[i].xlat_ == id) { |
233 happy_[i].timed_out_ = true; | 233 happy_[i].timed_out_ = true; |
234 happy_[i].task_ = NULL; | 234 happy_[i].task_ = nullptr; |
235 break; | 235 break; |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
239 // getting a bad ID here is a failure, but let's continue | 239 // getting a bad ID here is a failure, but let's continue |
240 // running to see what else might go wrong | 240 // running to see what else might go wrong |
241 EXPECT_LT(i, HAPPY_TASK_COUNT); | 241 EXPECT_LT(i, HAPPY_TASK_COUNT); |
242 } | 242 } |
243 | 243 |
244 void OnDoneHappy(const int id) { | 244 void OnDoneHappy(const int id) { |
245 int i; | 245 int i; |
246 for (i = 0; i < HAPPY_TASK_COUNT; ++i) { | 246 for (i = 0; i < HAPPY_TASK_COUNT; ++i) { |
247 if (happy_[i].xlat_ == id) { | 247 if (happy_[i].xlat_ == id) { |
248 happy_[i].task_ = NULL; | 248 happy_[i].task_ = nullptr; |
249 break; | 249 break; |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 // getting a bad ID here is a failure, but let's continue | 253 // getting a bad ID here is a failure, but let's continue |
254 // running to see what else might go wrong | 254 // running to see what else might go wrong |
255 EXPECT_LT(i, HAPPY_TASK_COUNT); | 255 EXPECT_LT(i, HAPPY_TASK_COUNT); |
256 } | 256 } |
257 | 257 |
258 void check_passed() { | 258 void check_passed() { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 } | 340 } |
341 | 341 |
342 // Test for aborting a task to verify that it does the Wake operation | 342 // Test for aborting a task to verify that it does the Wake operation |
343 // which gets it deleted. | 343 // which gets it deleted. |
344 | 344 |
345 class SetBoolOnDeleteTask : public Task { | 345 class SetBoolOnDeleteTask : public Task { |
346 public: | 346 public: |
347 SetBoolOnDeleteTask(TaskParent *parent, bool *set_when_deleted) | 347 SetBoolOnDeleteTask(TaskParent *parent, bool *set_when_deleted) |
348 : Task(parent), | 348 : Task(parent), |
349 set_when_deleted_(set_when_deleted) { | 349 set_when_deleted_(set_when_deleted) { |
350 EXPECT_TRUE(NULL != set_when_deleted); | 350 EXPECT_TRUE(nullptr != set_when_deleted); |
351 EXPECT_FALSE(*set_when_deleted); | 351 EXPECT_FALSE(*set_when_deleted); |
352 } | 352 } |
353 | 353 |
354 virtual ~SetBoolOnDeleteTask() { | 354 virtual ~SetBoolOnDeleteTask() { |
355 *set_when_deleted_ = true; | 355 *set_when_deleted_ = true; |
356 } | 356 } |
357 | 357 |
358 virtual int ProcessStart() { | 358 virtual int ProcessStart() { |
359 return STATE_BLOCKED; | 359 return STATE_BLOCKED; |
360 } | 360 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 459 } |
460 Thread::Current()->socketserver()->Wait(500, false); | 460 Thread::Current()->socketserver()->Wait(500, false); |
461 } | 461 } |
462 } | 462 } |
463 | 463 |
464 private: | 464 private: |
465 void OnTimeoutId(const int id) { | 465 void OnTimeoutId(const int id) { |
466 for (size_t i = 0; i < arraysize(stuck_tasks_); ++i) { | 466 for (size_t i = 0; i < arraysize(stuck_tasks_); ++i) { |
467 if (stuck_tasks_[i] && stuck_tasks_[i]->unique_id() == id) { | 467 if (stuck_tasks_[i] && stuck_tasks_[i]->unique_id() == id) { |
468 task_count_--; | 468 task_count_--; |
469 stuck_tasks_[i] = NULL; | 469 stuck_tasks_[i] = nullptr; |
470 break; | 470 break; |
471 } | 471 } |
472 } | 472 } |
473 } | 473 } |
474 | 474 |
475 MyTaskRunner task_runner_; | 475 MyTaskRunner task_runner_; |
476 StuckTask* (stuck_tasks_[3]); | 476 StuckTask* (stuck_tasks_[3]); |
477 int task_count_; | 477 int task_count_; |
478 RTC_DISALLOW_COPY_AND_ASSIGN(TimeoutChangeTest); | 478 RTC_DISALLOW_COPY_AND_ASSIGN(TimeoutChangeTest); |
479 }; | 479 }; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 // Do not start the task. | 533 // Do not start the task. |
534 // Note: this leaks memory, so don't do this. | 534 // Note: this leaks memory, so don't do this. |
535 // Instead, always run your tasks or delete them. | 535 // Instead, always run your tasks or delete them. |
536 new HappyTask(happy_task); | 536 new HappyTask(happy_task); |
537 | 537 |
538 // run the unblocked tasks | 538 // run the unblocked tasks |
539 task_runner.RunTasks(); | 539 task_runner.RunTasks(); |
540 } | 540 } |
541 | 541 |
542 } // namespace rtc | 542 } // namespace rtc |
OLD | NEW |