// Implement 16-byte atomic pair using the seq-lock synchronization algorithm. // This is currently only used for DexCache. // // This uses top 4-bytes of the key as version counter and lock bit, // which means the stored pair key can not use those bytes. // // This allows us to read the cache without exclusive access to the cache line. // // The 8-byte atomic pair uses the normal single-instruction implementation. // static constexpr uint64_t kSeqMask = (0xFFFFFFFFull << 32); static constexpr uint64_t kSeqLock = (0x80000000ull << 32); static constexpr uint64_t kSeqIncr = (0x00000001ull << 32); static constexpr uint kAtomicPairMaxSpins = 10'000u; static constexpr uint kAtomicPairSleepNanos = 100'000u;
// std::pair<> is not trivially copyable and as such it is unsuitable for atomic operations. template <typename IntType> struct PACKED(2 * sizeof(IntType)) AtomicPair {
static_assert(std::is_integral_v<IntType>);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.