Source
stdlib/memory/policy.hpp
1
// Copyright (c) 2026 BigBrain LLC. MIT-licensed (see LICENSE).2
// Original work; see ACKNOWLEDGMENTS.md for the open-source ideas we build upon.3
#pragma once5
/**6
* @file policy.hpp7
* @brief `memory` scheduling policy + the immediate-write priority constant.8
*/10
#include <cstdint>12
namespace cheatah::memory {14
/// How the owner schedules pending writes against reads. Chosen at construction (a stored value).15
/// NOTE: the current coordinator is writer-preferring under BOTH values — a renewing reader waits16
/// until the write queue is empty (today both behave as `writes_first`); `interleave` records the17
/// declared fairness intent.18
enum class policy : std::uint8_t {19
interleave, ///< (default) readers renew *between* writes; writers + waiting readers are fair.20
writes_first, ///< drain the ENTIRE write queue before renewing any reader (owner's declared choice).21
};22
/// Shorthand for `policy::interleave` — readers renew between writes (the default, fair) policy.23
inline constexpr policy interleave = policy::interleave;24
/// Shorthand for `policy::writes_first` — drain the whole write queue before renewing any reader.25
inline constexpr policy writes_first = policy::writes_first;27
/// The readable spelling of an immediate-write priority. Any negative priority is immediate; this is28
/// simply its name: `x.rwrite<memory::immediate>()` reads better than `x.rwrite<-1>()`.29
inline constexpr long long immediate = -1;31
} // namespace cheatah::memory