Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: webrtc/rtc_base/messagequeue.h

Issue 2915253002: Delete SignalThread class. (Closed)
Patch Set: Another TODO on moving to QueuedTask. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/rtc_base/BUILD.gn ('k') | webrtc/rtc_base/messagequeue.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/rtc_base/messagequeue.h
diff --git a/webrtc/rtc_base/messagequeue.h b/webrtc/rtc_base/messagequeue.h
index 4e534fa2fa6862a42c7ebe542959538b81c0e8ab..c8e247da474239b45cd46ee8b04403883be320c2 100644
--- a/webrtc/rtc_base/messagequeue.h
+++ b/webrtc/rtc_base/messagequeue.h
@@ -147,6 +147,23 @@ class DisposeData : public MessageData {
T* data_;
};
+// TODO(nisse): Replace RunnableData and FunctorData by a subclass of Message
+// owning a QueuedTask.
+class RunnableData : public MessageData {
+ public:
+ virtual void Run() = 0;
+};
+
+template <class FunctorT>
+class FunctorData : public RunnableData {
+ public:
+ explicit FunctorData(FunctorT functor) : functor_(std::move(functor)) {}
+ void Run() override { functor_(); }
+
+ private:
+ FunctorT functor_;
+};
+
const uint32_t MQID_ANY = static_cast<uint32_t>(-1);
const uint32_t MQID_DISPOSE = static_cast<uint32_t>(-2);
@@ -236,6 +253,19 @@ class MessageQueue {
uint32_t id = 0,
MessageData* pdata = nullptr,
bool time_sensitive = false);
+
+ // TODO(nisse): Replace with a method for posting a
+ // std::unique_ptr<QueuedTask>, to ease gradual conversion to using TaskQueue.
+ template <class FunctorT,
+ // Additional type check, or else it collides with calls to the
+ // above Post method with the optional arguments omitted.
+ typename std::enable_if<!std::is_pointer<FunctorT>::value>::type* =
+ nullptr>
+ void Post(const Location& posted_from, FunctorT functor) {
+ PostFunctorInternal(posted_from,
+ new FunctorData<FunctorT>(std::move(functor)));
+ }
+
virtual void PostDelayed(const Location& posted_from,
int cmsDelay,
MessageHandler* phandler,
@@ -312,6 +342,9 @@ class MessageQueue {
bool fDestroyed_;
private:
+ void PostFunctorInternal(const Location& posted_from,
+ RunnableData* message_data);
+
volatile int stop_;
// The SocketServer might not be owned by MessageQueue.
« no previous file with comments | « webrtc/rtc_base/BUILD.gn ('k') | webrtc/rtc_base/messagequeue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698