| 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 |
| 11 | #include "rtc_base/message_handler.h" |
| 12 |
| 13 | #include "rtc_base/thread.h" |
| 14 |
| 15 | namespace rtc { |
| 16 |
| 17 | MessageHandlerAutoCleanup::MessageHandlerAutoCleanup() {} |
| 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 | } |
| 29 |
| 30 | } // namespace rtc |
| 31 |