In rtc::Thread delete legacy implementation of the task queue
Bug: webrtc:14245 Change-Id: Ic0ad82f0eb2186367e794bbdc122de5b2f49204a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/268902 Auto-Submit: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37600}
This commit is contained in:
parent
f8e91dfdf4
commit
7e8299b62e
@ -1022,20 +1022,6 @@ void Thread::ClearCurrentTaskQueue() {
|
|||||||
task_queue_registration_.reset();
|
task_queue_registration_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::QueuedTaskHandler::OnMessage(Message* msg) {
|
|
||||||
RTC_DCHECK(msg);
|
|
||||||
auto* data = static_cast<ScopedMessageData<webrtc::QueuedTask>*>(msg->pdata);
|
|
||||||
std::unique_ptr<webrtc::QueuedTask> task(data->Release());
|
|
||||||
// Thread expects handler to own Message::pdata when OnMessage is called
|
|
||||||
// Since MessageData is no longer needed, delete it.
|
|
||||||
delete data;
|
|
||||||
|
|
||||||
// QueuedTask interface uses Run return value to communicate who owns the
|
|
||||||
// task. false means QueuedTask took the ownership.
|
|
||||||
if (!task->Run())
|
|
||||||
task.release();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Thread::AllowInvokesToThread(Thread* thread) {
|
void Thread::AllowInvokesToThread(Thread* thread) {
|
||||||
#if (!defined(NDEBUG) || RTC_DCHECK_IS_ON)
|
#if (!defined(NDEBUG) || RTC_DCHECK_IS_ON)
|
||||||
if (!IsCurrent()) {
|
if (!IsCurrent()) {
|
||||||
@ -1090,28 +1076,6 @@ bool Thread::IsInvokeToThreadAllowed(rtc::Thread* target) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::PostTask(std::unique_ptr<webrtc::QueuedTask> task) {
|
|
||||||
// Though Post takes MessageData by raw pointer (last parameter), it still
|
|
||||||
// takes it with ownership.
|
|
||||||
Post(RTC_FROM_HERE, &queued_task_handler_,
|
|
||||||
/*id=*/0, new ScopedMessageData<webrtc::QueuedTask>(std::move(task)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Thread::PostDelayedTask(std::unique_ptr<webrtc::QueuedTask> task,
|
|
||||||
uint32_t milliseconds) {
|
|
||||||
// This implementation does not support low precision yet.
|
|
||||||
PostDelayedHighPrecisionTask(std::move(task), milliseconds);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Thread::PostDelayedHighPrecisionTask(
|
|
||||||
std::unique_ptr<webrtc::QueuedTask> task,
|
|
||||||
uint32_t milliseconds) {
|
|
||||||
// Though PostDelayed takes MessageData by raw pointer (last parameter),
|
|
||||||
// it still takes it with ownership.
|
|
||||||
PostDelayed(RTC_FROM_HERE, milliseconds, &queued_task_handler_, /*id=*/0,
|
|
||||||
new ScopedMessageData<webrtc::QueuedTask>(std::move(task)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Thread::Delete() {
|
void Thread::Delete() {
|
||||||
Stop();
|
Stop();
|
||||||
delete this;
|
delete this;
|
||||||
|
|||||||
@ -30,7 +30,6 @@
|
|||||||
#include "absl/base/attributes.h"
|
#include "absl/base/attributes.h"
|
||||||
#include "absl/functional/any_invocable.h"
|
#include "absl/functional/any_invocable.h"
|
||||||
#include "api/function_view.h"
|
#include "api/function_view.h"
|
||||||
#include "api/task_queue/queued_task.h"
|
|
||||||
#include "api/task_queue/task_queue_base.h"
|
#include "api/task_queue/task_queue_base.h"
|
||||||
#include "api/units/time_delta.h"
|
#include "api/units/time_delta.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
@ -400,24 +399,6 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase {
|
|||||||
void PostDelayedHighPrecisionTask(absl::AnyInvocable<void() &&> task,
|
void PostDelayedHighPrecisionTask(absl::AnyInvocable<void() &&> task,
|
||||||
webrtc::TimeDelta delay) override;
|
webrtc::TimeDelta delay) override;
|
||||||
|
|
||||||
// Legacy TaskQueueBase methods, do not use in new code.
|
|
||||||
// TODO(bugs.webrtc.org/14245): Delete when all code that use rtc::Thread
|
|
||||||
// directly is updated to use PostTask methods above.
|
|
||||||
void PostTask(std::unique_ptr<webrtc::QueuedTask> task) override;
|
|
||||||
void PostDelayedTask(std::unique_ptr<webrtc::QueuedTask> task,
|
|
||||||
uint32_t milliseconds) override;
|
|
||||||
void PostDelayedHighPrecisionTask(std::unique_ptr<webrtc::QueuedTask> task,
|
|
||||||
uint32_t milliseconds) override;
|
|
||||||
|
|
||||||
// Legacy helper method, do not use in new code.
|
|
||||||
// TODO(bugs.webrtc.org/14245): Delete when all code that use rtc::Thread
|
|
||||||
// directly is updated to use PostTask methods above.
|
|
||||||
ABSL_DEPRECATED("Pass delay as webrtc::TimeDelta type")
|
|
||||||
void PostDelayedTask(absl::AnyInvocable<void() &&> task,
|
|
||||||
uint32_t milliseconds) {
|
|
||||||
PostDelayedTask(std::move(task), webrtc::TimeDelta::Millis(milliseconds));
|
|
||||||
}
|
|
||||||
|
|
||||||
// ProcessMessages will process I/O and dispatch messages until:
|
// ProcessMessages will process I/O and dispatch messages until:
|
||||||
// 1) cms milliseconds have elapsed (returns true)
|
// 1) cms milliseconds have elapsed (returns true)
|
||||||
// 2) Stop() is called (returns false)
|
// 2) Stop() is called (returns false)
|
||||||
@ -541,12 +522,6 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase {
|
|||||||
private:
|
private:
|
||||||
static const int kSlowDispatchLoggingThreshold = 50; // 50 ms
|
static const int kSlowDispatchLoggingThreshold = 50; // 50 ms
|
||||||
|
|
||||||
class QueuedTaskHandler final : public MessageHandler {
|
|
||||||
public:
|
|
||||||
QueuedTaskHandler() {}
|
|
||||||
void OnMessage(Message* msg) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Sets the per-thread allow-blocking-calls flag and returns the previous
|
// Sets the per-thread allow-blocking-calls flag and returns the previous
|
||||||
// value. Must be called on this thread.
|
// value. Must be called on this thread.
|
||||||
bool SetAllowBlockingCalls(bool allow);
|
bool SetAllowBlockingCalls(bool allow);
|
||||||
@ -621,8 +596,6 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase {
|
|||||||
// Only touched from the worker thread itself.
|
// Only touched from the worker thread itself.
|
||||||
bool blocking_calls_allowed_ = true;
|
bool blocking_calls_allowed_ = true;
|
||||||
|
|
||||||
// Runs webrtc::QueuedTask posted to the Thread.
|
|
||||||
QueuedTaskHandler queued_task_handler_;
|
|
||||||
std::unique_ptr<TaskQueueBase::CurrentTaskQueueSetter>
|
std::unique_ptr<TaskQueueBase::CurrentTaskQueueSetter>
|
||||||
task_queue_registration_;
|
task_queue_registration_;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user