henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2004 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 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #include "rtc_base/message_handler.h" |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 12 | |
Sebastian Jansson | 6ea2c6a | 2020-01-13 14:07:22 +0100 | [diff] [blame] | 13 | #include "rtc_base/thread.h" |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 14 | |
| 15 | namespace rtc { |
| 16 | |
Tomas Gunnarsson | 77baeee | 2020-09-24 22:39:21 +0200 | [diff] [blame] | 17 | MessageHandlerAutoCleanup::MessageHandlerAutoCleanup() {} |
Tomas Gunnarsson | 1235941 | 2020-09-11 23:48:54 +0200 | [diff] [blame] | 18 | |
| 19 | MessageHandlerAutoCleanup::~MessageHandlerAutoCleanup() { |
| 20 | // Note that even though this clears currently pending messages for the |
| 21 | // message handler, it's still racy since it doesn't prevent threads that |
| 22 | // might be in the process of posting new messages with would-be dangling |
| 23 | // pointers. |
| 24 | // This is related to the design of Message having a raw pointer. |
| 25 | // We could consider whether it would be safer to require message handlers |
| 26 | // to be reference counted (as some are). |
| 27 | ThreadManager::Clear(this); |
| 28 | } |
Tomas Gunnarsson | abdb470 | 2020-09-05 18:43:36 +0200 | [diff] [blame] | 29 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 30 | } // namespace rtc |