2014-05-13 18:00:26 +00:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#ifndef RTC_BASE_MESSAGE_HANDLER_H_
|
|
|
|
|
#define RTC_BASE_MESSAGE_HANDLER_H_
|
2014-05-13 18:00:26 +00:00
|
|
|
|
2017-06-29 07:52:50 +02:00
|
|
|
#include <utility>
|
2015-12-17 03:04:15 -08:00
|
|
|
|
2019-11-29 15:19:27 +01:00
|
|
|
#include "api/function_view.h"
|
2019-09-23 14:54:28 +02:00
|
|
|
#include "rtc_base/system/rtc_export.h"
|
2017-06-29 07:52:50 +02:00
|
|
|
|
|
|
|
|
namespace rtc {
|
|
|
|
|
|
|
|
|
|
struct Message;
|
|
|
|
|
|
2020-09-24 22:39:21 +02:00
|
|
|
// MessageQueue/Thread Messages get dispatched via the MessageHandler interface.
|
2019-09-23 14:54:28 +02:00
|
|
|
class RTC_EXPORT MessageHandler {
|
2017-06-29 07:52:50 +02:00
|
|
|
public:
|
2020-09-24 22:39:21 +02:00
|
|
|
virtual ~MessageHandler() {}
|
2017-06-29 07:52:50 +02:00
|
|
|
virtual void OnMessage(Message* msg) = 0;
|
2020-09-05 18:43:36 +02:00
|
|
|
};
|
|
|
|
|
|
2020-09-24 22:39:21 +02:00
|
|
|
// Warning: Provided for backwards compatibility.
|
|
|
|
|
//
|
|
|
|
|
// This class performs expensive cleanup in the dtor that will affect all
|
|
|
|
|
// instances of Thread (and their pending message queues) and will block the
|
|
|
|
|
// current thread as well as all other threads.
|
2020-09-05 18:43:36 +02:00
|
|
|
class RTC_EXPORT MessageHandlerAutoCleanup : public MessageHandler {
|
|
|
|
|
public:
|
|
|
|
|
~MessageHandlerAutoCleanup() override;
|
|
|
|
|
|
2022-01-12 05:24:58 +09:00
|
|
|
MessageHandlerAutoCleanup(const MessageHandlerAutoCleanup&) = delete;
|
|
|
|
|
MessageHandlerAutoCleanup& operator=(const MessageHandlerAutoCleanup&) =
|
|
|
|
|
delete;
|
|
|
|
|
|
2020-09-05 18:43:36 +02:00
|
|
|
protected:
|
2020-09-11 23:48:54 +02:00
|
|
|
MessageHandlerAutoCleanup();
|
2017-06-29 07:52:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace rtc
|
2014-05-13 18:00:26 +00:00
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#endif // RTC_BASE_MESSAGE_HANDLER_H_
|