message_handler.h 1.4 KB

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