mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-27 00:31:02 +08:00
Add inline function getCurrentThreadId
This commit is contained in:
parent
e61404c92c
commit
be11666ea3
@ -1,5 +1,5 @@
|
||||
#include "profiler/profiler.h"
|
||||
|
||||
#include "profile_manager.h"
|
||||
#include <ctime>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
@ -25,7 +25,7 @@ Block::Block(const char* _name, color_t _color, block_type_t _type) :
|
||||
{
|
||||
end = begin;
|
||||
}
|
||||
thread_id = std::hash<std::thread::id>()(std::this_thread::get_id());
|
||||
thread_id = getCurrentThreadId();
|
||||
}
|
||||
|
||||
void BaseBlockData::tick(timestamp_t& stamp)
|
||||
|
@ -122,7 +122,7 @@ void ProfileManager::endBlock()
|
||||
if (!m_isEnabled)
|
||||
return;
|
||||
|
||||
uint32_t threadId = getThreadId();
|
||||
uint32_t threadId = getCurrentThreadId();
|
||||
|
||||
guard_lock_t lock(m_spin);
|
||||
auto& stackOfOpenedBlocks = m_openedBracketsMap[threadId];
|
||||
@ -156,7 +156,7 @@ void ProfileManager::_internalInsertBlock(profiler::Block* _block)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
uint32_t ProfileManager::getThreadId()
|
||||
uint32_t getCurrentThreadId()
|
||||
{
|
||||
#ifdef WIN32
|
||||
return (uint32_t)::GetCurrentThreadId();
|
||||
|
@ -27,6 +27,8 @@ along with this program.If not, see <http://www.gnu.org/licenses/>.
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
||||
inline uint32_t getCurrentThreadId();
|
||||
|
||||
class ProfileManager
|
||||
{
|
||||
ProfileManager();
|
||||
@ -50,7 +52,7 @@ class ProfileManager
|
||||
typedef std::list<profiler::SerilizedBlock*> serialized_list_t;
|
||||
serialized_list_t m_blocks;
|
||||
|
||||
uint32_t getThreadId();
|
||||
|
||||
public:
|
||||
static ProfileManager& instance();
|
||||
~ProfileManager();
|
||||
|
Loading…
x
Reference in New Issue
Block a user