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

Side by Side Diff: base/message_loop.cc

Issue 6142009: Upating the app, ceee, chrome, ipc, media, and net directories to use the correct lock.h file. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Unified patch updating all references to the new base/synchronization/lock.h Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « base/message_loop.h ('k') | base/message_loop_proxy_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/message_loop.h" 5 #include "base/message_loop.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 void MessageLoop::ReloadWorkQueue() { 387 void MessageLoop::ReloadWorkQueue() {
388 // We can improve performance of our loading tasks from incoming_queue_ to 388 // We can improve performance of our loading tasks from incoming_queue_ to
389 // work_queue_ by waiting until the last minute (work_queue_ is empty) to 389 // work_queue_ by waiting until the last minute (work_queue_ is empty) to
390 // load. That reduces the number of locks-per-task significantly when our 390 // load. That reduces the number of locks-per-task significantly when our
391 // queues get large. 391 // queues get large.
392 if (!work_queue_.empty()) 392 if (!work_queue_.empty())
393 return; // Wait till we *really* need to lock and load. 393 return; // Wait till we *really* need to lock and load.
394 394
395 // Acquire all we can from the inter-thread queue with one lock acquisition. 395 // Acquire all we can from the inter-thread queue with one lock acquisition.
396 { 396 {
397 AutoLock lock(incoming_queue_lock_); 397 base::AutoLock lock(incoming_queue_lock_);
398 if (incoming_queue_.empty()) 398 if (incoming_queue_.empty())
399 return; 399 return;
400 incoming_queue_.Swap(&work_queue_); // Constant time 400 incoming_queue_.Swap(&work_queue_); // Constant time
401 DCHECK(incoming_queue_.empty()); 401 DCHECK(incoming_queue_.empty());
402 } 402 }
403 } 403 }
404 404
405 bool MessageLoop::DeletePendingTasks() { 405 bool MessageLoop::DeletePendingTasks() {
406 bool did_work = !work_queue_.empty(); 406 bool did_work = !work_queue_.empty();
407 while (!work_queue_.empty()) { 407 while (!work_queue_.empty()) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 } 488 }
489 } 489 }
490 #endif 490 #endif
491 491
492 // Warning: Don't try to short-circuit, and handle this thread's tasks more 492 // Warning: Don't try to short-circuit, and handle this thread's tasks more
493 // directly, as it could starve handling of foreign threads. Put every task 493 // directly, as it could starve handling of foreign threads. Put every task
494 // into this queue. 494 // into this queue.
495 495
496 scoped_refptr<base::MessagePump> pump; 496 scoped_refptr<base::MessagePump> pump;
497 { 497 {
498 AutoLock locked(incoming_queue_lock_); 498 base::AutoLock locked(incoming_queue_lock_);
499 499
500 bool was_empty = incoming_queue_.empty(); 500 bool was_empty = incoming_queue_.empty();
501 incoming_queue_.push(pending_task); 501 incoming_queue_.push(pending_task);
502 if (!was_empty) 502 if (!was_empty)
503 return; // Someone else should have started the sub-pump. 503 return; // Someone else should have started the sub-pump.
504 504
505 pump = pump_; 505 pump = pump_;
506 } 506 }
507 // Since the incoming_queue_ may contain a task that destroys this message 507 // Since the incoming_queue_ may contain a task that destroys this message
508 // loop, we cannot exit incoming_queue_lock_ until we are done with |this|. 508 // loop, we cannot exit incoming_queue_lock_ until we are done with |this|.
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 Watcher *delegate) { 696 Watcher *delegate) {
697 return pump_libevent()->WatchFileDescriptor( 697 return pump_libevent()->WatchFileDescriptor(
698 fd, 698 fd,
699 persistent, 699 persistent,
700 static_cast<base::MessagePumpLibevent::Mode>(mode), 700 static_cast<base::MessagePumpLibevent::Mode>(mode),
701 controller, 701 controller,
702 delegate); 702 delegate);
703 } 703 }
704 704
705 #endif 705 #endif
OLDNEW
« no previous file with comments | « base/message_loop.h ('k') | base/message_loop_proxy_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698