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

Side by Side Diff: webrtc/base/messagequeue.cc

Issue 2915253002: Delete SignalThread class. (Closed)
Patch Set: Fix template magic. Naming and formatting fixes. Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 #include <algorithm> 10 #include <algorithm>
(...skipping 26 matching lines...) Expand all
37 *locked_ = false; 37 *locked_ = false;
38 cs_->Leave(); 38 cs_->Leave();
39 } 39 }
40 40
41 private: 41 private:
42 const CriticalSection* const cs_; 42 const CriticalSection* const cs_;
43 bool* locked_; 43 bool* locked_;
44 44
45 RTC_DISALLOW_COPY_AND_ASSIGN(DebugNonReentrantCritScope); 45 RTC_DISALLOW_COPY_AND_ASSIGN(DebugNonReentrantCritScope);
46 }; 46 };
47
48 class FunctorPostMessageHandler : public MessageHandler {
49 public:
50 void OnMessage(Message* msg) override {
51 CallableData* data = static_cast<CallableData*>(msg->pdata);
52 data->Call();
53 delete data;
54 }
55 };
56
47 } // namespace 57 } // namespace
48 58
49 //------------------------------------------------------------------ 59 //------------------------------------------------------------------
50 // MessageQueueManager 60 // MessageQueueManager
51 61
52 MessageQueueManager* MessageQueueManager::instance_ = nullptr; 62 MessageQueueManager* MessageQueueManager::instance_ = nullptr;
53 63
54 MessageQueueManager* MessageQueueManager::Instance() { 64 MessageQueueManager* MessageQueueManager::Instance() {
55 // Note: This is not thread safe, but it is first called before threads are 65 // Note: This is not thread safe, but it is first called before threads are
56 // spawned. 66 // spawned.
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 371
362 void MessageQueue::ReceiveSends() { 372 void MessageQueue::ReceiveSends() {
363 } 373 }
364 374
365 void MessageQueue::Post(const Location& posted_from, 375 void MessageQueue::Post(const Location& posted_from,
366 MessageHandler* phandler, 376 MessageHandler* phandler,
367 uint32_t id, 377 uint32_t id,
368 MessageData* pdata, 378 MessageData* pdata,
369 bool time_sensitive) { 379 bool time_sensitive) {
370 if (IsQuitting()) 380 if (IsQuitting())
371 return; 381 return;
nisse-webrtc 2017/06/27 08:27:17 Unrelated to this cl, but shouldn't this code call
tommi 2017/06/27 12:01:14 depends - I think there might be call sites that c
nisse-webrtc 2017/06/28 11:47:54 I was thinking that we should handle discarded mes
372 382
373 // Keep thread safe 383 // Keep thread safe
374 // Add the message to the end of the queue 384 // Add the message to the end of the queue
375 // Signal for the multiplexer to return 385 // Signal for the multiplexer to return
376 386
377 { 387 {
378 CritScope cs(&crit_); 388 CritScope cs(&crit_);
379 Message msg; 389 Message msg;
380 msg.posted_from = posted_from; 390 msg.posted_from = posted_from;
381 msg.phandler = phandler; 391 msg.phandler = phandler;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 int64_t start_time = TimeMillis(); 532 int64_t start_time = TimeMillis();
523 pmsg->phandler->OnMessage(pmsg); 533 pmsg->phandler->OnMessage(pmsg);
524 int64_t end_time = TimeMillis(); 534 int64_t end_time = TimeMillis();
525 int64_t diff = TimeDiff(end_time, start_time); 535 int64_t diff = TimeDiff(end_time, start_time);
526 if (diff >= kSlowDispatchLoggingThreshold) { 536 if (diff >= kSlowDispatchLoggingThreshold) {
527 LOG(LS_INFO) << "Message took " << diff << "ms to dispatch. Posted from: " 537 LOG(LS_INFO) << "Message took " << diff << "ms to dispatch. Posted from: "
528 << pmsg->posted_from.ToString(); 538 << pmsg->posted_from.ToString();
529 } 539 }
530 } 540 }
531 541
542 void MessageQueue::PostFunctorInternal(const Location& posted_from,
543 CallableData* message_data) {
544 // Use static to ensure it outlives this scope. Safe since
545 // FunctorPostMessageHandler keeps no state.
546 static FunctorPostMessageHandler handler;
547 Post(posted_from, &handler, 0, message_data);
548 }
549
532 } // namespace rtc 550 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698