mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Send lock events.
This commit is contained in:
parent
78f8425dc7
commit
0011573fa9
@ -1,6 +1,7 @@
|
||||
#ifndef __TRACYLOCK_HPP__
|
||||
#define __TRACYLOCK_HPP__
|
||||
|
||||
#include "../common/TracySystem.hpp"
|
||||
#include "TracyProfiler.hpp"
|
||||
|
||||
namespace tracy
|
||||
@ -26,17 +27,64 @@ public:
|
||||
|
||||
void lock()
|
||||
{
|
||||
int8_t cpu;
|
||||
const auto thread = GetThreadHandle();
|
||||
{
|
||||
Magic magic;
|
||||
auto& token = s_token;
|
||||
auto item = s_queue.enqueue_begin( token, magic );
|
||||
item->hdr.type = QueueType::LockWait;
|
||||
item->lockWait.id = (uint64_t)&m_lockable;
|
||||
item->lockWait.thread = thread;
|
||||
item->lockWait.time = Profiler::GetTime( item->zoneBegin.cpu );
|
||||
s_queue.enqueue_finish( token, magic );
|
||||
}
|
||||
|
||||
m_lockable.lock();
|
||||
|
||||
{
|
||||
Magic magic;
|
||||
auto& token = s_token;
|
||||
auto item = s_queue.enqueue_begin( token, magic );
|
||||
item->hdr.type = QueueType::LockObtain;
|
||||
item->lockObtain.id = (uint64_t)&m_lockable;
|
||||
item->lockObtain.thread = thread;
|
||||
item->lockObtain.time = Profiler::GetTime( item->zoneBegin.cpu );
|
||||
s_queue.enqueue_finish( token, magic );
|
||||
}
|
||||
}
|
||||
|
||||
void unlock()
|
||||
{
|
||||
m_lockable.unlock();
|
||||
|
||||
int8_t cpu;
|
||||
Magic magic;
|
||||
auto& token = s_token;
|
||||
auto item = s_queue.enqueue_begin( token, magic );
|
||||
item->hdr.type = QueueType::LockRelease;
|
||||
item->lockRelease.id = (uint64_t)&m_lockable;
|
||||
item->lockRelease.thread = GetThreadHandle();
|
||||
item->lockRelease.time = Profiler::GetTime( item->zoneBegin.cpu );
|
||||
s_queue.enqueue_finish( token, magic );
|
||||
}
|
||||
|
||||
bool try_lock()
|
||||
{
|
||||
return m_lockable.try_lock();
|
||||
const auto ret = m_lockable.try_lock();
|
||||
if( ret )
|
||||
{
|
||||
int8_t cpu;
|
||||
Magic magic;
|
||||
auto& token = s_token;
|
||||
auto item = s_queue.enqueue_begin( token, magic );
|
||||
item->hdr.type = QueueType::LockObtain;
|
||||
item->lockObtain.id = (uint64_t)&m_lockable;
|
||||
item->lockObtain.thread = GetThreadHandle();
|
||||
item->lockObtain.time = Profiler::GetTime( item->zoneBegin.cpu );
|
||||
s_queue.enqueue_finish( token, magic );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -80,14 +80,23 @@ struct QueueLockAnnounce
|
||||
|
||||
struct QueueLockWait
|
||||
{
|
||||
uint64_t id; // ptr
|
||||
int64_t time;
|
||||
uint64_t thread;
|
||||
};
|
||||
|
||||
struct QueueLockObtain
|
||||
{
|
||||
uint64_t id; // ptr
|
||||
int64_t time;
|
||||
uint64_t thread;
|
||||
};
|
||||
|
||||
struct QueueLockRelease
|
||||
{
|
||||
uint64_t id; // ptr
|
||||
int64_t time;
|
||||
uint64_t thread;
|
||||
};
|
||||
|
||||
struct QueueHeader
|
||||
|
@ -376,6 +376,12 @@ void View::Process( const QueueItem& ev )
|
||||
case QueueType::LockAnnounce:
|
||||
ProcessLockAnnounce( ev.lockAnnounce );
|
||||
break;
|
||||
case QueueType::LockWait:
|
||||
break;
|
||||
case QueueType::LockObtain:
|
||||
break;
|
||||
case QueueType::LockRelease:
|
||||
break;
|
||||
default:
|
||||
assert( false );
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user