mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-10 01:50:53 +09:00
8
This commit is contained in:
parent
dd91c63355
commit
b58de909fb
1 changed files with 8 additions and 8 deletions
|
@ -138,7 +138,7 @@ private:
|
|||
// 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.
|
||||
// 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.
|
||||
// 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);
|
||||
|
||||
//// 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 spins = rand >> (uint8_t)((uint32_t)32 - min(collisions, MaxExponentialBackoffBits));
|
||||
//for (int i = 0; i < (int)spins; i++)
|
||||
//{
|
||||
// YieldProcessor();
|
||||
//}
|
||||
// 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 spins = rand >> (uint8_t)((uint32_t)32 - min(collisions, MaxExponentialBackoffBits));
|
||||
for (int i = 0; i < (int)spins; i++)
|
||||
{
|
||||
YieldProcessor();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue