Create conversions between webrtc::TaskQueueBase and rtc::TaskQueue
Bug: webrtc:10191 Change-Id: Ia6642081ac758e31c14780bdd83dbc88279cce6d Reviewed-on: https://webrtc-review.googlesource.com/c/124826 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26890}
This commit is contained in:
parent
c85328f2ca
commit
f3280e99b0
@ -14,14 +14,21 @@
|
||||
|
||||
namespace rtc {
|
||||
|
||||
TaskQueue::TaskQueue(const char* queue_name, Priority priority)
|
||||
: impl_(webrtc::GlobalTaskQueueFactory()
|
||||
.CreateTaskQueue(queue_name, priority)
|
||||
.release()) {
|
||||
TaskQueue::TaskQueue(
|
||||
std::unique_ptr<webrtc::TaskQueueBase, webrtc::TaskQueueDeleter> task_queue)
|
||||
: impl_(task_queue.release()) {
|
||||
impl_->task_queue_ = this;
|
||||
}
|
||||
|
||||
TaskQueue::TaskQueue(const char* queue_name, Priority priority)
|
||||
: TaskQueue(webrtc::GlobalTaskQueueFactory().CreateTaskQueue(queue_name,
|
||||
priority)) {}
|
||||
|
||||
TaskQueue::~TaskQueue() {
|
||||
// There might running task that tries to rescheduler itself to the TaskQueue
|
||||
// and not yet aware TaskQueue destructor is called.
|
||||
// Calling back to TaskQueue::PostTask need impl_ pointer still be valid, so
|
||||
// do not invalidate impl_ pointer until Delete returns.
|
||||
impl_->Delete();
|
||||
}
|
||||
|
||||
|
||||
@ -145,6 +145,8 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueue {
|
||||
// priorities, on others such as Mac and iOS, GCD queue priorities.
|
||||
using Priority = ::webrtc::TaskQueueFactory::Priority;
|
||||
|
||||
explicit TaskQueue(std::unique_ptr<webrtc::TaskQueueBase,
|
||||
webrtc::TaskQueueDeleter> task_queue);
|
||||
explicit TaskQueue(const char* queue_name,
|
||||
Priority priority = Priority::NORMAL);
|
||||
~TaskQueue();
|
||||
@ -154,6 +156,9 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueue {
|
||||
// Used for DCHECKing the current queue.
|
||||
bool IsCurrent() const;
|
||||
|
||||
// Returns non-owning pointer to the task queue implementation.
|
||||
webrtc::TaskQueueBase* Get() { return impl_; }
|
||||
|
||||
// TODO(tommi): For better debuggability, implement RTC_FROM_HERE.
|
||||
|
||||
// Ownership of the task is passed to PostTask.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user