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

Issue 1608: Create a LazyInstance abstraction. (Closed)

Created:
12 years, 3 months ago by Dean McNamee
Modified:
9 years, 7 months ago
CC:
chromium-reviews_googlegroups.com
Visibility:
Public.

Description

Create a LazyInstance abstraction for avoiding static constructors by lazily creating an instance of an object on first access. This is like Singleton, but without the Singleton property of sharing instances. This also preallocates space for the object to avoid the heap to try to help fragmentation and creation performance. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=1837

Patch Set 1 #

Patch Set 2 : '' #

Patch Set 3 : '' #

Patch Set 4 : '' #

Patch Set 5 : '' #

Patch Set 6 : '' #

Patch Set 7 : '' #

Patch Set 8 : '' #

Patch Set 9 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+253 lines, -0 lines) Patch
M base/SConscript View 1 2 3 4 5 6 2 chunks +2 lines, -0 lines 0 comments Download
M base/build/base.vcproj View 1 2 3 4 5 6 1 chunk +8 lines, -0 lines 0 comments Download
M base/build/base_unittests.vcproj View 1 2 3 4 5 6 1 chunk +4 lines, -0 lines 0 comments Download
A base/lazy_instance.h View 1 2 3 1 chunk +105 lines, -0 lines 1 comment Download
A base/lazy_instance.cc View 1 chunk +34 lines, -0 lines 0 comments Download
A base/lazy_instance_unittest.cc View 1 2 3 4 5 6 7 8 1 chunk +100 lines, -0 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
Dean McNamee
I think in a lot of situations we're abusing Singleton, when really we don't want ...
12 years, 3 months ago (2008-09-07 14:51:49 UTC) #1
darin (slow to review)
LGTM http://codereview.chromium.org/1608/diff/1/2 File base/lazy_instance.h (right): http://codereview.chromium.org/1608/diff/1/2#newcode12 Line 12: // LazyInstance is completely thread safe, assuming ...
12 years, 3 months ago (2008-09-07 18:48:19 UTC) #2
darin (slow to review)
btw... couldn't Singleton<T> be re-implemented in terms of LazyInstance<T>? Perhaps a Singleton<T> could just have ...
12 years, 3 months ago (2008-09-07 18:48:50 UTC) #3
cpu_(ooo_6.6-7.5)
http://codereview.chromium.org/1608/diff/1/2 File base/lazy_instance.h (right): http://codereview.chromium.org/1608/diff/1/2#newcode20 Line 20: // to avoid allocating the Type instance on ...
12 years, 3 months ago (2008-09-07 20:05:32 UTC) #4
Mark Mentovai
Don't let the comments scare you, this looks good. http://codereview.chromium.org/1608/diff/1/2 File base/lazy_instance.h (right): http://codereview.chromium.org/1608/diff/1/2#newcode1 Line ...
12 years, 3 months ago (2008-09-07 23:26:27 UTC) #5
M-A Ruel
Not much left to say with Darin and Mark comments. :) lgtm http://codereview.chromium.org/1608/diff/1/3 File base/SConscript ...
12 years, 3 months ago (2008-09-08 01:01:46 UTC) #6
M-A Ruel
still lgtm http://codereview.chromium.org/1608/diff/272/38 File base/lazy_instance.h (right): http://codereview.chromium.org/1608/diff/272/38#newcode98 Line 98: int8 buf_[sizeof(Type)]; // Preallocate the space ...
12 years, 3 months ago (2008-09-08 13:56:35 UTC) #7
Mark Mentovai
I'm satisfied now, LGTM
12 years, 3 months ago (2008-09-08 13:56:50 UTC) #8
darin (slow to review)
12 years, 3 months ago (2008-09-08 16:13:00 UTC) #9
LGTM

Powered by Google App Engine
This is Rietveld 408576698