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

Side by Side Diff: Source/core/dom/DOMArrayBufferDeallocationObserver.cpp

Issue 794223003: Cheaper thread-safe atomic initialization of static references. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add type check for initial value Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "core/dom/DOMArrayBufferDeallocationObserver.h" 6 #include "core/dom/DOMArrayBufferDeallocationObserver.h"
7 7
8 #include "wtf/Threading.h" 8 #include "wtf/Threading.h"
9 #include <v8.h> 9 #include <v8.h>
10 10
11 namespace blink { 11 namespace blink {
12 12
13 DOMArrayBufferDeallocationObserver* DOMArrayBufferDeallocationObserver::instance () 13 DOMArrayBufferDeallocationObserver& DOMArrayBufferDeallocationObserver::instance ()
14 { 14 {
15 AtomicallyInitializedStatic( 15 AtomicallyInitializedStaticReference(DOMArrayBufferDeallocationObserver, dea llocationObserver, new DOMArrayBufferDeallocationObserver);
16 DOMArrayBufferDeallocationObserver*,
17 deallocationObserver = new DOMArrayBufferDeallocationObserver);
18 return deallocationObserver; 16 return deallocationObserver;
19 } 17 }
20 18
21 void DOMArrayBufferDeallocationObserver::arrayBufferDeallocated(unsigned sizeInB ytes) 19 void DOMArrayBufferDeallocationObserver::arrayBufferDeallocated(unsigned sizeInB ytes)
22 { 20 {
23 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-static_cas t<int>(sizeInBytes)); 21 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-static_cas t<int>(sizeInBytes));
24 } 22 }
25 23
26 void DOMArrayBufferDeallocationObserver::blinkAllocatedMemory(unsigned sizeInByt es) 24 void DOMArrayBufferDeallocationObserver::blinkAllocatedMemory(unsigned sizeInByt es)
27 { 25 {
28 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(static_cast <int>(sizeInBytes)); 26 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(static_cast <int>(sizeInBytes));
29 } 27 }
30 28
31 } // namespace blink 29 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698