Add lock termination event.

This commit is contained in:
Bartosz Taudul 2018-12-16 20:37:48 +01:00
parent 61ac0b8afc
commit 0b816ce0b7
2 changed files with 46 additions and 0 deletions

View File

@ -46,6 +46,24 @@ public:
Lockable( const Lockable& ) = delete; Lockable( const Lockable& ) = delete;
Lockable& operator=( const Lockable& ) = delete; Lockable& operator=( const Lockable& ) = delete;
~Lockable()
{
Magic magic;
auto& token = s_token.ptr;
auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::LockTerminate );
MemWrite( &item->lockTerminate.id, m_id );
MemWrite( &item->lockTerminate.time, Profiler::GetTime() );
MemWrite( &item->lockTerminate.type, LockType::Lockable );
#ifdef TRACY_ON_DEMAND
s_profiler.DeferItem( *item );
#endif
tail.store( magic + 1, std::memory_order_release );
}
tracy_force_inline void lock() tracy_force_inline void lock()
{ {
#ifdef TRACY_ON_DEMAND #ifdef TRACY_ON_DEMAND
@ -221,6 +239,24 @@ public:
SharedLockable( const SharedLockable& ) = delete; SharedLockable( const SharedLockable& ) = delete;
SharedLockable& operator=( const SharedLockable& ) = delete; SharedLockable& operator=( const SharedLockable& ) = delete;
~SharedLockable()
{
Magic magic;
auto& token = s_token.ptr;
auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::LockTerminate );
MemWrite( &item->lockTerminate.id, m_id );
MemWrite( &item->lockTerminate.time, Profiler::GetTime() );
MemWrite( &item->lockTerminate.type, LockType::SharedLockable );
#ifdef TRACY_ON_DEMAND
s_profiler.DeferItem( *item );
#endif
tail.store( magic + 1, std::memory_order_release );
}
tracy_force_inline void lock() tracy_force_inline void lock()
{ {
#ifdef TRACY_ON_DEMAND #ifdef TRACY_ON_DEMAND

View File

@ -26,6 +26,7 @@ enum class QueueType : uint8_t
FrameMarkMsgEnd, FrameMarkMsgEnd,
SourceLocation, SourceLocation,
LockAnnounce, LockAnnounce,
LockTerminate,
LockWait, LockWait,
LockObtain, LockObtain,
LockRelease, LockRelease,
@ -114,6 +115,13 @@ struct QueueLockAnnounce
LockType type; LockType type;
}; };
struct QueueLockTerminate
{
uint32_t id;
int64_t time;
LockType type;
};
struct QueueLockWait struct QueueLockWait
{ {
uint32_t id; uint32_t id;
@ -265,6 +273,7 @@ struct QueueItem
QueueSourceLocation srcloc; QueueSourceLocation srcloc;
QueueZoneText zoneText; QueueZoneText zoneText;
QueueLockAnnounce lockAnnounce; QueueLockAnnounce lockAnnounce;
QueueLockTerminate lockTerminate;
QueueLockWait lockWait; QueueLockWait lockWait;
QueueLockObtain lockObtain; QueueLockObtain lockObtain;
QueueLockRelease lockRelease; QueueLockRelease lockRelease;
@ -308,6 +317,7 @@ static const size_t QueueDataSize[] = {
sizeof( QueueHeader ) + sizeof( QueueFrameMark ), // end sizeof( QueueHeader ) + sizeof( QueueFrameMark ), // end
sizeof( QueueHeader ) + sizeof( QueueSourceLocation ), sizeof( QueueHeader ) + sizeof( QueueSourceLocation ),
sizeof( QueueHeader ) + sizeof( QueueLockAnnounce ), sizeof( QueueHeader ) + sizeof( QueueLockAnnounce ),
sizeof( QueueHeader ) + sizeof( QueueLockTerminate ),
sizeof( QueueHeader ) + sizeof( QueueLockWait ), sizeof( QueueHeader ) + sizeof( QueueLockWait ),
sizeof( QueueHeader ) + sizeof( QueueLockObtain ), sizeof( QueueHeader ) + sizeof( QueueLockObtain ),
sizeof( QueueHeader ) + sizeof( QueueLockRelease ), sizeof( QueueHeader ) + sizeof( QueueLockRelease ),