proxygen
CachelinePadded.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <cstddef>
20 #include <utility>
21 
22 #include <folly/lang/Align.h>
23 
24 namespace folly {
25 
36 template <typename T>
38  static_assert(
39  alignof(T) <= max_align_v,
40  "CachelinePadded does not support over-aligned types.");
41 
42  public:
43  template <typename... Args>
44  explicit CachelinePadded(Args&&... args)
45  : inner_(std::forward<Args>(args)...) {}
46 
47  T* get() {
48  return &inner_;
49  }
50 
51  const T* get() const {
52  return &inner_;
53  }
54 
56  return get();
57  }
58 
59  const T* operator->() const {
60  return get();
61  }
62 
63  T& operator*() {
64  return *get();
65  }
66 
67  const T& operator*() const {
68  return *get();
69  }
70 
71  private:
72  static constexpr size_t paddingSize() noexcept {
75  }
79 };
80 } // namespace folly
const T * operator->() const
STL namespace.
char paddingPost_[paddingSize()]
folly::std T
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
requires E e noexcept(noexcept(s.error(std::move(e))))
char paddingPre_[paddingSize()]
constexpr std::size_t max_align_v
Definition: Align.h:90
constexpr std::size_t hardware_destructive_interference_size
Definition: Align.h:107
const T & operator*() const
CachelinePadded(Args &&...args)
static constexpr size_t paddingSize() noexcept