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

Side by Side Diff: base/allocator/allocator_shim.h

Issue 2556563002: Make InsertAllocatorDispatch thread safe. (Closed)
Patch Set: Remove the now-redundant single-thread check. Created 4 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
« no previous file with comments | « no previous file | base/allocator/allocator_shim.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ 5 #ifndef BASE_ALLOCATOR_ALLOCATOR_SHIM_H_
6 #define BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ 6 #define BASE_ALLOCATOR_ALLOCATOR_SHIM_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 }; 79 };
80 80
81 // When true makes malloc behave like new, w.r.t calling the new_handler if 81 // When true makes malloc behave like new, w.r.t calling the new_handler if
82 // the allocation fails (see set_new_mode() in Windows). 82 // the allocation fails (see set_new_mode() in Windows).
83 BASE_EXPORT void SetCallNewHandlerOnMallocFailure(bool value); 83 BASE_EXPORT void SetCallNewHandlerOnMallocFailure(bool value);
84 84
85 // Allocates |size| bytes or returns nullptr. It does NOT call the new_handler, 85 // Allocates |size| bytes or returns nullptr. It does NOT call the new_handler,
86 // regardless of SetCallNewHandlerOnMallocFailure(). 86 // regardless of SetCallNewHandlerOnMallocFailure().
87 BASE_EXPORT void* UncheckedAlloc(size_t size); 87 BASE_EXPORT void* UncheckedAlloc(size_t size);
88 88
89 // Inserts |dispatch| in front of the allocator chain. This method is NOT 89 // Inserts |dispatch| in front of the allocator chain. This method is
90 // thread-safe w.r.t concurrent invocations of InsertAllocatorDispatch(). 90 // thread-safe w.r.t concurrent invocations of InsertAllocatorDispatch().
91 // The callers have the responsibility of linearizing the changes to the chain 91 // The callers have responsibility for inserting a single dispatch no more
92 // (or more likely call these always on the same thread). 92 // than once.
93 BASE_EXPORT void InsertAllocatorDispatch(AllocatorDispatch* dispatch); 93 BASE_EXPORT void InsertAllocatorDispatch(AllocatorDispatch* dispatch);
94 94
95 // Test-only. Rationale: (1) lack of use cases; (2) dealing safely with a 95 // Test-only. Rationale: (1) lack of use cases; (2) dealing safely with a
96 // removal of arbitrary elements from a singly linked list would require a lock 96 // removal of arbitrary elements from a singly linked list would require a lock
97 // in malloc(), which we really don't want. 97 // in malloc(), which we really don't want.
98 BASE_EXPORT void RemoveAllocatorDispatchForTesting(AllocatorDispatch* dispatch); 98 BASE_EXPORT void RemoveAllocatorDispatchForTesting(AllocatorDispatch* dispatch);
99 99
100 } // namespace allocator 100 } // namespace allocator
101 } // namespace base 101 } // namespace base
102 102
103 #endif // BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ 103 #endif // BASE_ALLOCATOR_ALLOCATOR_SHIM_H_
OLDNEW
« no previous file with comments | « no previous file | base/allocator/allocator_shim.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698