mirror of
https://github.com/wolfpld/tracy
synced 2025-04-30 04:43:53 +00:00
Send lock events.
This commit is contained in:
parent
78f8425dc7
commit
0011573fa9
@ -1,6 +1,7 @@
|
|||||||
#ifndef __TRACYLOCK_HPP__
|
#ifndef __TRACYLOCK_HPP__
|
||||||
#define __TRACYLOCK_HPP__
|
#define __TRACYLOCK_HPP__
|
||||||
|
|
||||||
|
#include "../common/TracySystem.hpp"
|
||||||
#include "TracyProfiler.hpp"
|
#include "TracyProfiler.hpp"
|
||||||
|
|
||||||
namespace tracy
|
namespace tracy
|
||||||
@ -26,17 +27,64 @@ public:
|
|||||||
|
|
||||||
void lock()
|
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();
|
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()
|
void unlock()
|
||||||
{
|
{
|
||||||
m_lockable.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()
|
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:
|
private:
|
||||||
|
@ -80,14 +80,23 @@ struct QueueLockAnnounce
|
|||||||
|
|
||||||
struct QueueLockWait
|
struct QueueLockWait
|
||||||
{
|
{
|
||||||
|
uint64_t id; // ptr
|
||||||
|
int64_t time;
|
||||||
|
uint64_t thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct QueueLockObtain
|
struct QueueLockObtain
|
||||||
{
|
{
|
||||||
|
uint64_t id; // ptr
|
||||||
|
int64_t time;
|
||||||
|
uint64_t thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct QueueLockRelease
|
struct QueueLockRelease
|
||||||
{
|
{
|
||||||
|
uint64_t id; // ptr
|
||||||
|
int64_t time;
|
||||||
|
uint64_t thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct QueueHeader
|
struct QueueHeader
|
||||||
|
@ -376,6 +376,12 @@ void View::Process( const QueueItem& ev )
|
|||||||
case QueueType::LockAnnounce:
|
case QueueType::LockAnnounce:
|
||||||
ProcessLockAnnounce( ev.lockAnnounce );
|
ProcessLockAnnounce( ev.lockAnnounce );
|
||||||
break;
|
break;
|
||||||
|
case QueueType::LockWait:
|
||||||
|
break;
|
||||||
|
case QueueType::LockObtain:
|
||||||
|
break;
|
||||||
|
case QueueType::LockRelease:
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert( false );
|
assert( false );
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user