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

Side by Side Diff: base/message_loop/message_loop.cc

Issue 2235283002: Fix incorrect memory barrier usage I previously asked to be introduced. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « base/message_loop/message_loop.h ('k') | base/task_scheduler/scheduler_worker_pool_impl.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 else 411 else
412 pump_ = CreateMessagePumpForType(type_); 412 pump_ = CreateMessagePumpForType(type_);
413 413
414 DCHECK(!current()) << "should only have one message loop per thread"; 414 DCHECK(!current()) << "should only have one message loop per thread";
415 lazy_tls_ptr.Pointer()->Set(this); 415 lazy_tls_ptr.Pointer()->Set(this);
416 416
417 incoming_task_queue_->StartScheduling(); 417 incoming_task_queue_->StartScheduling();
418 unbound_task_runner_->BindToCurrentThread(); 418 unbound_task_runner_->BindToCurrentThread();
419 unbound_task_runner_ = nullptr; 419 unbound_task_runner_ = nullptr;
420 SetThreadTaskRunnerHandle(); 420 SetThreadTaskRunnerHandle();
421 { 421 thread_id_ = PlatformThread::CurrentId();
422 // Save the current thread's ID for potential use by other threads
423 // later from GetThreadName().
424 thread_id_ = PlatformThread::CurrentId();
425 subtle::MemoryBarrier();
426 }
427 } 422 }
428 423
429 std::string MessageLoop::GetThreadName() const { 424 std::string MessageLoop::GetThreadName() const {
430 if (thread_id_ == kInvalidThreadId) { 425 DCHECK_NE(kInvalidThreadId, thread_id_)
431 // |thread_id_| may already have been initialized but this thread might not 426 << "GetThreadName() must only be called after BindToCurrentThread()'s "
432 // have received the update yet. 427 << "side-effects have been synchronized with this thread.";
433 subtle::MemoryBarrier();
434 DCHECK_NE(kInvalidThreadId, thread_id_);
435 }
436 return ThreadIdNameManager::GetInstance()->GetName(thread_id_); 428 return ThreadIdNameManager::GetInstance()->GetName(thread_id_);
437 } 429 }
438 430
439 void MessageLoop::SetTaskRunner( 431 void MessageLoop::SetTaskRunner(
440 scoped_refptr<SingleThreadTaskRunner> task_runner) { 432 scoped_refptr<SingleThreadTaskRunner> task_runner) {
441 DCHECK_EQ(this, current()); 433 DCHECK_EQ(this, current());
442 DCHECK(task_runner->BelongsToCurrentThread()); 434 DCHECK(task_runner->BelongsToCurrentThread());
443 DCHECK(!unbound_task_runner_); 435 DCHECK(!unbound_task_runner_);
444 task_runner_ = std::move(task_runner); 436 task_runner_ = std::move(task_runner);
445 SetThreadTaskRunnerHandle(); 437 SetThreadTaskRunnerHandle();
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 persistent, 763 persistent,
772 mode, 764 mode,
773 controller, 765 controller,
774 delegate); 766 delegate);
775 } 767 }
776 #endif 768 #endif
777 769
778 #endif // !defined(OS_NACL_SFI) 770 #endif // !defined(OS_NACL_SFI)
779 771
780 } // namespace base 772 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_loop.h ('k') | base/task_scheduler/scheduler_worker_pool_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698