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

Side by Side Diff: rlz/lib/recursive_lock.cc

Issue 11308196: [cros] RlzValueStore made protected by a cross-process lock and not persisted over browser lifetime… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years 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 | « rlz/lib/recursive_lock.h ('k') | rlz/lib/recursive_lock_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "rlz/lib/recursive_lock.h"
6
7 #include "base/logging.h"
8
9 namespace rlz_lib {
10
11 RecursiveLock::RecursiveLock()
12 : owner_(),
13 recursion_() {
14 }
15
16 RecursiveLock::~RecursiveLock() {
17 }
18
19 void RecursiveLock::Acquire() {
20 base::subtle::Atomic32 me = base::PlatformThread::CurrentId();
21 if (me != base::subtle::NoBarrier_Load(&owner_)) {
22 lock_.Acquire();
23 DCHECK(!recursion_);
24 DCHECK(!owner_);
25 base::subtle::NoBarrier_Store(&owner_, me);
26 }
27 ++recursion_;
28 }
29
30 void RecursiveLock::Release() {
31 DCHECK_EQ(base::subtle::NoBarrier_Load(&owner_),
32 base::PlatformThread::CurrentId());
33 DCHECK_GT(recursion_, 0);
34 if (!--recursion_) {
35 base::subtle::NoBarrier_Store(&owner_, 0);
36 lock_.Release();
37 }
38 }
39
40 } // namespace rlz_lib
OLDNEW
« no previous file with comments | « rlz/lib/recursive_lock.h ('k') | rlz/lib/recursive_lock_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698