You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright 2019 The WebRTC Project Authors. All rights reserved.
  3. *
  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
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #include "rtc_base/task_queue.h"
  11. #include "api/task_queue/task_queue_base.h"
  12. namespace rtc {
  13. TaskQueue::TaskQueue(
  14. std::unique_ptr<webrtc::TaskQueueBase, webrtc::TaskQueueDeleter> task_queue)
  15. : impl_(task_queue.release()) {}
  16. TaskQueue::~TaskQueue() {
  17. // There might running task that tries to rescheduler itself to the TaskQueue
  18. // and not yet aware TaskQueue destructor is called.
  19. // Calling back to TaskQueue::PostTask need impl_ pointer still be valid, so
  20. // do not invalidate impl_ pointer until Delete returns.
  21. impl_->Delete();
  22. }
  23. bool TaskQueue::IsCurrent() const {
  24. return impl_->IsCurrent();
  25. }
  26. void TaskQueue::PostTask(std::unique_ptr<webrtc::QueuedTask> task) {
  27. return impl_->PostTask(std::move(task));
  28. }
  29. void TaskQueue::PostDelayedTask(std::unique_ptr<webrtc::QueuedTask> task,
  30. uint32_t milliseconds) {
  31. return impl_->PostDelayedTask(std::move(task), milliseconds);
  32. }
  33. } // namespace rtc