mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Separate processing of Lockable and SharedLockable.
This commit is contained in:
parent
6f1a99e270
commit
b3b8088881
@ -2852,6 +2852,97 @@ static Vector<LockEvent*>::iterator GetNextLockEvent( const Vector<LockEvent*>::
|
|||||||
auto next = it;
|
auto next = it;
|
||||||
next++;
|
next++;
|
||||||
|
|
||||||
|
switch( nextState )
|
||||||
|
{
|
||||||
|
case LockState::Nothing:
|
||||||
|
while( next < end )
|
||||||
|
{
|
||||||
|
if( (*next)->lockCount != 0 )
|
||||||
|
{
|
||||||
|
if( GetThreadBit( (*next)->lockingThread ) == threadBit )
|
||||||
|
{
|
||||||
|
nextState = AreOtherWaiting( (*next)->waitList, threadBit ) ? LockState::HasBlockingLock : LockState::HasLock;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if( IsThreadWaiting( (*next)->waitList, threadBit ) )
|
||||||
|
{
|
||||||
|
nextState = LockState::WaitLock;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
next++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LockState::HasLock:
|
||||||
|
while( next < end )
|
||||||
|
{
|
||||||
|
if( (*next)->lockCount == 0 )
|
||||||
|
{
|
||||||
|
nextState = LockState::Nothing;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if( (*next)->waitList != 0 )
|
||||||
|
{
|
||||||
|
if( AreOtherWaiting( (*next)->waitList, threadBit ) )
|
||||||
|
{
|
||||||
|
nextState = LockState::HasBlockingLock;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if( (*next)->waitList != (*it)->waitList || (*next)->lockCount != (*it)->lockCount )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
next++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LockState::HasBlockingLock:
|
||||||
|
while( next < end )
|
||||||
|
{
|
||||||
|
if( (*next)->lockCount == 0 )
|
||||||
|
{
|
||||||
|
nextState = LockState::Nothing;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if( (*next)->waitList != (*it)->waitList || (*next)->lockCount != (*it)->lockCount )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
next++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LockState::WaitLock:
|
||||||
|
while( next < end )
|
||||||
|
{
|
||||||
|
if( GetThreadBit( (*next)->lockingThread ) == threadBit )
|
||||||
|
{
|
||||||
|
nextState = AreOtherWaiting( (*next)->waitList, threadBit ) ? LockState::HasBlockingLock : LockState::HasLock;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if( (*next)->lockingThread != (*it)->lockingThread )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if( (*next)->lockCount == 0 )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
next++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert( false );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Vector<LockEvent*>::iterator GetNextLockEventShared( const Vector<LockEvent*>::iterator& it, const Vector<LockEvent*>::iterator& end, LockState& nextState, uint64_t threadBit )
|
||||||
|
{
|
||||||
|
auto next = it;
|
||||||
|
next++;
|
||||||
|
|
||||||
switch( nextState )
|
switch( nextState )
|
||||||
{
|
{
|
||||||
case LockState::Nothing:
|
case LockState::Nothing:
|
||||||
@ -2987,6 +3078,8 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos,
|
|||||||
assert( !tl.empty() );
|
assert( !tl.empty() );
|
||||||
if( tl.back()->time < m_zvStart ) continue;
|
if( tl.back()->time < m_zvStart ) continue;
|
||||||
|
|
||||||
|
auto GetNextLockFunc = lockmap.type == LockType::Lockable ? GetNextLockEvent : GetNextLockEventShared;
|
||||||
|
|
||||||
const auto thread = it->second;
|
const auto thread = it->second;
|
||||||
const auto threadBit = GetThreadBit( thread );
|
const auto threadBit = GetThreadBit( thread );
|
||||||
|
|
||||||
@ -3000,32 +3093,49 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos,
|
|||||||
const auto offset = _offset + ostep * cnt;
|
const auto offset = _offset + ostep * cnt;
|
||||||
|
|
||||||
LockState state = LockState::Nothing;
|
LockState state = LockState::Nothing;
|
||||||
if( (*vbegin)->lockCount != 0 )
|
if( lockmap.type == LockType::Lockable )
|
||||||
{
|
{
|
||||||
if( (*vbegin)->lockingThread == thread )
|
if( (*vbegin)->lockCount != 0 )
|
||||||
{
|
{
|
||||||
state = ( AreOtherWaiting( (*vbegin)->waitList, threadBit ) || AreOtherWaiting( (*vbegin)->waitShared, threadBit ) ) ? LockState::HasBlockingLock : LockState::HasLock;
|
if( (*vbegin)->lockingThread == thread )
|
||||||
|
{
|
||||||
|
state = AreOtherWaiting( (*vbegin)->waitList, threadBit ) ? LockState::HasBlockingLock : LockState::HasLock;
|
||||||
|
}
|
||||||
|
else if( IsThreadWaiting( (*vbegin)->waitList, threadBit ) )
|
||||||
|
{
|
||||||
|
state = LockState::WaitLock;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( IsThreadWaiting( (*vbegin)->waitList, threadBit ) || IsThreadWaiting( (*vbegin)->waitShared, threadBit ) )
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( (*vbegin)->lockCount != 0 )
|
||||||
|
{
|
||||||
|
if( (*vbegin)->lockingThread == thread )
|
||||||
|
{
|
||||||
|
state = ( AreOtherWaiting( (*vbegin)->waitList, threadBit ) || AreOtherWaiting( (*vbegin)->waitShared, threadBit ) ) ? LockState::HasBlockingLock : LockState::HasLock;
|
||||||
|
}
|
||||||
|
else if( IsThreadWaiting( (*vbegin)->waitList, threadBit ) || IsThreadWaiting( (*vbegin)->waitShared, threadBit ) )
|
||||||
|
{
|
||||||
|
state = LockState::WaitLock;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( IsThreadWaiting( (*vbegin)->sharedList, threadBit ) )
|
||||||
|
{
|
||||||
|
state = (*vbegin)->waitList != 0 ? LockState::HasBlockingLock : LockState::HasLock;
|
||||||
|
}
|
||||||
|
else if( (*vbegin)->sharedList != 0 && IsThreadWaiting( (*vbegin)->waitList, threadBit ) )
|
||||||
{
|
{
|
||||||
state = LockState::WaitLock;
|
state = LockState::WaitLock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( IsThreadWaiting( (*vbegin)->sharedList, threadBit ) )
|
|
||||||
{
|
|
||||||
state = (*vbegin)->waitList != 0 ? LockState::HasBlockingLock : LockState::HasLock;
|
|
||||||
}
|
|
||||||
else if( (*vbegin)->sharedList != 0 && IsThreadWaiting( (*vbegin)->waitList, threadBit ) )
|
|
||||||
{
|
|
||||||
state = LockState::WaitLock;
|
|
||||||
}
|
|
||||||
|
|
||||||
double pxend = 0;
|
double pxend = 0;
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
while( vbegin < vend && ( state == LockState::Nothing || ( m_onlyContendedLocks && state == LockState::HasLock ) ) )
|
while( vbegin < vend && ( state == LockState::Nothing || ( m_onlyContendedLocks && state == LockState::HasLock ) ) )
|
||||||
{
|
{
|
||||||
vbegin = GetNextLockEvent( vbegin, vend, state, threadBit );
|
vbegin = GetNextLockFunc( vbegin, vend, state, threadBit );
|
||||||
}
|
}
|
||||||
if( vbegin >= vend ) break;
|
if( vbegin >= vend ) break;
|
||||||
|
|
||||||
@ -3033,7 +3143,7 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos,
|
|||||||
drawn = true;
|
drawn = true;
|
||||||
|
|
||||||
LockState drawState = state;
|
LockState drawState = state;
|
||||||
auto next = GetNextLockEvent( vbegin, vend, state, threadBit );
|
auto next = GetNextLockFunc( vbegin, vend, state, threadBit );
|
||||||
|
|
||||||
const auto t0 = (*vbegin)->time;
|
const auto t0 = (*vbegin)->time;
|
||||||
int64_t t1 = next == tl.end() ? m_lastTime : (*next)->time;
|
int64_t t1 = next == tl.end() ? m_lastTime : (*next)->time;
|
||||||
@ -3049,12 +3159,12 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos,
|
|||||||
auto ns = state;
|
auto ns = state;
|
||||||
while( n < vend && ( ns == LockState::Nothing || ( m_onlyContendedLocks && ns == LockState::HasLock ) ) )
|
while( n < vend && ( ns == LockState::Nothing || ( m_onlyContendedLocks && ns == LockState::HasLock ) ) )
|
||||||
{
|
{
|
||||||
n = GetNextLockEvent( n, vend, ns, threadBit );
|
n = GetNextLockFunc( n, vend, ns, threadBit );
|
||||||
}
|
}
|
||||||
if( n >= vend ) break;
|
if( n >= vend ) break;
|
||||||
if( n == next )
|
if( n == next )
|
||||||
{
|
{
|
||||||
n = GetNextLockEvent( n, vend, ns, threadBit );
|
n = GetNextLockFunc( n, vend, ns, threadBit );
|
||||||
}
|
}
|
||||||
drawState = CombineLockState( drawState, state );
|
drawState = CombineLockState( drawState, state );
|
||||||
condensed++;
|
condensed++;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user