0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-28 01:04:41 +08:00

Check thread expired on linux and add new message in easy_net

This commit is contained in:
Sergey Yagovtsev 2016-11-27 14:26:00 +03:00
parent a7ac056021
commit f788071003
3 changed files with 23 additions and 5 deletions

View File

@ -64,6 +64,7 @@ enum MessageType : uint8_t
MESSAGE_TYPE_EVENT_TRACING_STATUS,
MESSAGE_TYPE_EVENT_TRACING_PRIORITY,
MESSAGE_TYPE_CHECK_CONNECTION
};
struct Message

View File

@ -47,6 +47,10 @@
#include "event_trace_win.h"
#include "current_time.h"
#ifndef _WIN32
#include <signal.h>
#endif
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
@ -305,9 +309,10 @@ public:
//////////////////////////////////////////////////////////////////////////
ThreadStorage::ThreadStorage() : id(getCurrentThreadId()), allowChildren(true), named(false)
ThreadStorage::ThreadStorage() : id(getCurrentThreadId()), allowChildren(true), named(false), pthread_id(pthread_self())
{
expired = ATOMIC_VAR_INIT(false);
}
void ThreadStorage::storeBlock(const profiler::Block& block)
@ -671,14 +676,14 @@ bool ProfileManager::checkThreadExpired(ThreadStorage& _registeredThread)
if (hThread != nullptr)
CloseHandle(hThread);
return false;
#else
// TODO: Check thread for Linux
return pthread_kill(_registeredThread.pthread_id, 0) != 0;
#endif
return false;
}
//////////////////////////////////////////////////////////////////////////
@ -976,6 +981,13 @@ void ProfileManager::listen()
switch (message->type)
{
case profiler::net::MESSAGE_TYPE_CHECK_CONNECTION:
{
#ifdef EASY_DEBUG_NET_PRINT
printf("receive MESSAGE_TYPE_CHECK_CONNECTION\n");
#endif
break;
}
case profiler::net::MESSAGE_TYPE_REQUEST_START_CAPTURE:
{
#ifdef EASY_DEBUG_NET_PRINT

View File

@ -309,6 +309,11 @@ struct ThreadStorage
BlocksList<std::reference_wrapper<profiler::Block>, SIZEOF_CSWITCH * (uint16_t)128U> blocks;
BlocksList<profiler::Block, SIZEOF_CSWITCH * (uint16_t)128U> sync;
std::string name;
#ifndef _WIN32
const pthread_t pthread_id;
#endif
const profiler::thread_id_t id;
std::atomic_bool expired;
bool allowChildren;