qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches
prefix.h File Reference

Platform-specific alignment macros, cache-line definitions, and related utilities. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CacheLine
 A structure automatically aligned to cache line boundaries. More...
struct  EventBucket
 A structure aligned to event bucket boundaries, typically matching cache line size. More...

Macros

#define QB_LOCKFREE_CACHELINE_BYTES   cache_line_size()
#define QB_LOCKFREE_EVENT_BUCKET_BYTES   cache_line_size()

Functions

constexpr std::size_t cache_line_size ()
 Determines the optimal cache line size for the current platform at compile time.

Detailed Description

Platform-specific alignment macros, cache-line definitions, and related utilities.

This file provides platform-specific macros and constants crucial for performance-sensitive code, especially in lock-free algorithms and memory-efficient data structures. It defines:

  • QB_LOCKFREE_CACHELINE_BYTES: The detected or assumed cache line size.
  • QB_LOCKFREE_EVENT_BUCKET_BYTES: The size for event partitioning, often aligned to cache lines.
  • QB_LOCKFREE_PTR_COMPRESSION: A macro indicating if pointer compression techniques might be applicable (platform-dependent).
  • QB_LOCKFREE_CACHELINE_ALIGNMENT: Macro for aligning structs/classes to cache line boundaries (e.g., alignas or __declspec(align)).
  • QB_LOCKFREE_EVENT_BUCKET_ALIGNMENT: Macro for aligning to event bucket boundaries.
  • Helper structs CacheLine and EventBucket for creating correctly sized and aligned padding or base structures.

These are essential for optimizing memory layout to prevent false sharing and improve cache performance.

Author
qb - C++ Actor Framework

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.