OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // An arena that consists of a single inlined block of |ArenaSize|. Useful to | 5 // An arena that consists of a single inlined block of |ArenaSize|. Useful to |
6 // avoid repeated calls to malloc/new and to improve memory locality. DCHECK's | 6 // avoid repeated calls to malloc/new and to improve memory locality. DCHECK's |
7 // if an allocation out of the arena ever fails in debug builds; falls back to | 7 // if an allocation out of the arena ever fails in debug builds; falls back to |
8 // heap allocation in release builds. | 8 // heap allocation in release builds. |
9 | 9 |
10 #ifndef NET_QUIC_CORE_QUIC_ONE_BLOCK_ARENA_H_ | 10 #ifndef NET_QUIC_CORE_QUIC_ONE_BLOCK_ARENA_H_ |
11 #define NET_QUIC_CORE_QUIC_ONE_BLOCK_ARENA_H_ | 11 #define NET_QUIC_CORE_QUIC_ONE_BLOCK_ARENA_H_ |
12 | 12 |
13 #include <cstdint> | 13 #include <cstdint> |
14 | 14 |
15 #include "net/quic/core/quic_arena_scoped_ptr.h" | 15 #include "net/quic/core/quic_arena_scoped_ptr.h" |
16 #include "net/quic/core/quic_bug_tracker.h" | |
17 #include "net/quic/core/quic_types.h" | 16 #include "net/quic/core/quic_types.h" |
| 17 #include "net/quic/platform/api/quic_bug_tracker.h" |
18 | 18 |
19 #define PREDICT_FALSE(x) x | 19 #define PREDICT_FALSE(x) x |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 | 22 |
23 template <uint32_t ArenaSize> | 23 template <uint32_t ArenaSize> |
24 class QuicOneBlockArena { | 24 class QuicOneBlockArena { |
25 static const uint32_t kMaxAlign = 8; | 25 static const uint32_t kMaxAlign = 8; |
26 | 26 |
27 public: | 27 public: |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 void* buf = &storage_[offset_]; | 70 void* buf = &storage_[offset_]; |
71 new (buf) T(std::forward<Args>(args)...); | 71 new (buf) T(std::forward<Args>(args)...); |
72 offset_ += AlignedSize<T>(); | 72 offset_ += AlignedSize<T>(); |
73 return QuicArenaScopedPtr<T>(buf, | 73 return QuicArenaScopedPtr<T>(buf, |
74 QuicArenaScopedPtr<T>::ConstructFrom::kArena); | 74 QuicArenaScopedPtr<T>::ConstructFrom::kArena); |
75 } | 75 } |
76 | 76 |
77 } // namespace net | 77 } // namespace net |
78 | 78 |
79 #endif // NET_QUIC_CORE_QUIC_ONE_BLOCK_ARENA_H_ | 79 #endif // NET_QUIC_CORE_QUIC_ONE_BLOCK_ARENA_H_ |
OLD | NEW |