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

Issue 48109: Added a debug method AssertAcquired() that compiles to nothing in non-debug b... (Closed)

Created:
11 years, 9 months ago by ralphl
Modified:
9 years, 7 months ago
CC:
chromium-reviews_googlegroups.com, Alpha Left Google
Visibility:
Public.

Description

Added a debug method AssertAcquired() that compiles to nothing in non-debug builds. In debug builds, the method will DCHECK if the current thread does not hold the lock. I also removed a class that was not being used (AutoLockImpl) which seems like someone just copied the Lock.h file and blindly added an Impl for the AutoLock class. Thre are places in my code where I want to use the AutoUnlock class. I can't see why it was restricted to use by the condition variable class only, so I just made it into a regular class with no restrictions. I noticed that JamesR posted a CL about a month ago that made AutoUnlock a public class, but it was never committed, so I added him to this CL for review too. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=12037

Patch Set 1 #

Patch Set 2 : '' #

Total comments: 6

Patch Set 3 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+49 lines, -28 lines) Patch
M base/lock.h View 1 2 4 chunks +18 lines, -11 lines 0 comments Download
M base/lock_impl.h View 1 4 chunks +16 lines, -17 lines 0 comments Download
M base/lock_impl_win.cc View 1 2 4 chunks +15 lines, -0 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
ralphl
This is the change that kills the unit tests on mac and linux
11 years, 9 months ago (2009-03-17 23:26:51 UTC) #1
ralphl
JAR: I noticed you were the last person to change the lock_*. files, so I'm ...
11 years, 9 months ago (2009-03-18 18:08:44 UTC) #2
jar (doing other things)
Please address the items below before landing. After those changes are made, LGTM. Thanks, Jim ...
11 years, 9 months ago (2009-03-18 20:40:13 UTC) #3
jamesr1
Thanks for merging in the AutoUnlock changes - I haven't had a chance to follow ...
11 years, 9 months ago (2009-03-18 20:49:35 UTC) #4
ralphl
11 years, 9 months ago (2009-03-18 21:21:49 UTC) #5
OK, fixed it up.  Now letting the try servers have one more shot at it before
committing.

Next I'll check in the change that actually uses the AutoUnlock and
AssertAcquired() methods.

http://codereview.chromium.org/48109/diff/1001/12
File base/lock.h (right):

http://codereview.chromium.org/48109/diff/1001/12#newcode22
Line 22: void AssertAcquired() { return lock_.AssertAcquired(); }
On 2009/03/18 20:40:13, jar wrote:
> Please add a comment describing the semantics of this method.

Done.

http://codereview.chromium.org/48109/diff/1001/12#newcode52
Line 52: // A helper class which releases an acquired lock for a given scope.
On 2009/03/18 20:40:13, jar wrote:
> Consider using the original comment, or adding text that shows that the class
> does more than release (it re-acquires).

Done.

http://codereview.chromium.org/48109/diff/1001/11
File base/lock_impl_win.cc (right):

http://codereview.chromium.org/48109/diff/1001/11#newcode16
Line 16: owning_thread_id_ = 0;
On 2009/03/18 20:40:13, jar wrote:
> Is it true that CurrentId() never returns 0?
> 
> If so, you could assert it when you get the value "for real."

Done.

Powered by Google App Engine
This is Rietveld 408576698