1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-10 01:50:53 +09:00
This commit is contained in:
vsadov 2024-12-29 17:14:31 -08:00
parent dd91c63355
commit b58de909fb

View file

@ -138,7 +138,7 @@ private:
// will do a lot less attempts than an simple retry. On multiprocessor machine fruitless attempts // will do a lot less attempts than an simple retry. On multiprocessor machine fruitless attempts
// will cause unnecessary sharing of the contended state which may make modifying the state more expensive. // will cause unnecessary sharing of the contended state which may make modifying the state more expensive.
// To protect against degenerate cases we will cap the per-iteration wait to 1024 spinwaits. // To protect against degenerate cases we will cap the per-iteration wait to 1024 spinwaits.
static const uint32_t MaxExponentialBackoffBits = 10; static const uint32_t MaxExponentialBackoffBits = 8;
// This lock is unfair and permits acquiring a contended lock by a nonwaiter in the presence of waiters. // This lock is unfair and permits acquiring a contended lock by a nonwaiter in the presence of waiters.
// It is possible for one thread to keep holding the lock long enough that waiters go to sleep and // It is possible for one thread to keep holding the lock long enough that waiters go to sleep and
@ -220,13 +220,13 @@ public:
{ {
_ASSERTE(collisions > 0); _ASSERTE(collisions > 0);
//// no need for much randomness here, we will just hash the stack location and a timestamp. // no need for much randomness here, we will just hash the stack location and a timestamp.
//uint32_t rand = ((uint32_t)(size_t)&collisions + (uint32_t)GetCheapTimeStamp()) * 2654435769u; uint32_t rand = ((uint32_t)(size_t)&collisions + (uint32_t)GetCheapTimeStamp()) * 2654435769u;
//uint32_t spins = rand >> (uint8_t)((uint32_t)32 - min(collisions, MaxExponentialBackoffBits)); uint32_t spins = rand >> (uint8_t)((uint32_t)32 - min(collisions, MaxExponentialBackoffBits));
//for (int i = 0; i < (int)spins; i++) for (int i = 0; i < (int)spins; i++)
//{ {
// YieldProcessor(); YieldProcessor();
//} }
} }
private: private: