| 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 | #ifndef RTC_BASE_MESSAGE_HANDLER_H_ |
| 12 | #define RTC_BASE_MESSAGE_HANDLER_H_ |
| 13 |
| 14 | #include <utility> |
| 15 |
| 16 | #include "api/function_view.h" |
| 17 | #include "rtc_base/constructor_magic.h" |
| 18 | #include "rtc_base/system/rtc_export.h" |
| 19 |
| 20 | namespace rtc { |
| 21 |
| 22 | struct Message; |
| 23 |
| 24 | // MessageQueue/Thread Messages get dispatched via the MessageHandler interface. |
| 25 | class RTC_EXPORT MessageHandler { |
| 26 | public: |
| 27 | virtual ~MessageHandler() {} |
| 28 | virtual void OnMessage(Message* msg) = 0; |
| 29 | }; |
| 30 |
| 31 | // Warning: Provided for backwards compatibility. |
| 32 | // |
| 33 | // This class performs expensive cleanup in the dtor that will affect all |
| 34 | // instances of Thread (and their pending message queues) and will block the |
| 35 | // current thread as well as all other threads. |
| 36 | class RTC_EXPORT MessageHandlerAutoCleanup : public MessageHandler { |
| 37 | public: |
| 38 | ~MessageHandlerAutoCleanup() override; |
| 39 |
| 40 | protected: |
| 41 | MessageHandlerAutoCleanup(); |
| 42 |
| 43 | private: |
| 44 | RTC_DISALLOW_COPY_AND_ASSIGN(MessageHandlerAutoCleanup); |
| 45 | }; |
| 46 |
| 47 | } // namespace rtc |
| 48 |
| 49 | #endif // RTC_BASE_MESSAGE_HANDLER_H_ |
| 50 |