
This is the next step towards making MessageHandler a pure virtual interface. All dependencies that require automatic cleanup should be depending on the MessageHandlerAutoCleanup class. Next step will be to remove the ctor from MessageHandler and make it a pure virtual interface. Bug: webrtc:11908 Change-Id: I9321b6d9e57c167868f8b896a5345fbfe19af0e9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/183984 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Tommi <tommi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32090}
38 lines
1.3 KiB
C++
38 lines
1.3 KiB
C++
/*
|
|
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#include "rtc_base/message_handler.h"
|
|
|
|
#include "rtc_base/thread.h"
|
|
|
|
namespace rtc {
|
|
|
|
MessageHandler::MessageHandler(bool auto_cleanup) {
|
|
RTC_DCHECK(!auto_cleanup) << "Use MessageHandlerAutoCleanup";
|
|
}
|
|
|
|
MessageHandler::~MessageHandler() {}
|
|
|
|
MessageHandlerAutoCleanup::MessageHandlerAutoCleanup()
|
|
: MessageHandler(false) {}
|
|
|
|
MessageHandlerAutoCleanup::~MessageHandlerAutoCleanup() {
|
|
// Note that even though this clears currently pending messages for the
|
|
// message handler, it's still racy since it doesn't prevent threads that
|
|
// might be in the process of posting new messages with would-be dangling
|
|
// pointers.
|
|
// This is related to the design of Message having a raw pointer.
|
|
// We could consider whether it would be safer to require message handlers
|
|
// to be reference counted (as some are).
|
|
ThreadManager::Clear(this);
|
|
}
|
|
|
|
} // namespace rtc
|