本文整理汇总了C++中SetThreadName函数的典型用法代码示例。如果您正苦于以下问题:C++ SetThreadName函数的具体用法?C++ SetThreadName怎么用?C++ SetThreadName使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetThreadName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
SetThreadName("Main");
Logger.Info("UDPServer starting");
MyServer myserver;
auto settings = std::make_shared<ServerSettings>();
settings->WorkerCount = 0;
settings->MainTCPPort = 5060;
settings->StartUDPPort = 5060;
settings->StopUDPPort = 5061;
settings->Interface = &myserver;
Server server;
server.Start(settings);
for (;;)
{
std::this_thread::sleep_for(std::chrono::seconds(1));
}
server.Stop();
return 0;
}
示例2: Sleep
unsigned long FTPFileWriter::Process(void* parameter)
{
if(SETTINGS::getInstance().getFtpServerOn() == false) {
Sleep(500);
return 0;
}
SetThreadName("FtpFileWriter");
loopRunning = true;
waitingForBytes = true;
while(!done || !waitingForBytes)
{
if(!waitingForBytes)
{
fwrite(currentBuffer,(size_t)currentBufferSize,1,m_File);
delete currentBuffer;
waitingForBytes = true;
}
else
{
Sleep(0);
}
}
loopRunning = false;
return 0;
}
示例3: SetThreadName
DWORD WINAPI my12doomRendererDShow::queue_thread(LPVOID param)
{
my12doomRendererDShow * _this = (my12doomRendererDShow*)param;
SetThreadName(GetCurrentThreadId(), _this->m_id==0?"queue thread 0":"queue thread 1");
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
while (!_this->m_queue_exit)
{
CComPtr<IMediaSample> dummy_sample;
dummy_sample = NULL;
{
CAutoLock lck(&_this->m_queue_lock);
if (_this->m_queue_count)
{
_this->m_allocator->GetBuffer(&dummy_sample, &_this->m_queue->start, &_this->m_queue->end, NULL);
dummy_sample->SetTime(&_this->m_queue->start, &_this->m_queue->end);
memmove(_this->m_queue, _this->m_queue+1, sizeof(dummy_packet)*(my12doom_queue_size-1));
_this->m_queue_count--;
}
}
if(dummy_sample)
_this->SuperReceive(dummy_sample);
else
Sleep(1);
}
return 0;
}
示例4: SetThreadName
bool Database::run()
{
SetThreadName("Database Executor");
ThreadRunning = true;
string *query = queries_queue.pop();
DatabaseConnection &con = GetFreeConnection();
while(query)
{
_SendQuery( con, query->c_str(), false );
delete query;
if(!m_threadRunning)
break;
query = queries_queue.pop();
}
con.Busy.Release();
if(queries_queue.get_size() > 0)
{
// execute all the remaining queries
query = queries_queue.pop_nowait();
while(query)
{
DatabaseConnection &con = GetFreeConnection();
_SendQuery( con, query->c_str(), false );
con.Busy.Release();
delete query;
query=queries_queue.pop_nowait();
}
}
ThreadRunning = false;
return false;
}
示例5: SetThreadName
bool ConsoleThread::run()
{
SetThreadName("Console Interpreter");
size_t i = 0;
size_t len;
char cmd[300];
#ifndef WIN32
struct pollfd input;
input.fd = 0;
input.events = POLLIN | POLLPRI;
input.revents = 0;
#endif
m_killSwitch = false;
m_isRunning = true;
while( m_killSwitch != true )
{
#ifdef WIN32
// Read in single line from "stdin"
memset( cmd, 0, sizeof( cmd ) );
if( fgets( cmd, 300, stdin ) == NULL )
continue;
if( m_killSwitch )
break;
#else
int ret = poll(&input, 1, 1000);
if (ret < 0)
{
break;
}
else if( ret == 0 )
{
if(!m_killSwitch) // timeout
continue;
else
break;
}
ret = read(0, cmd, sizeof(cmd));
if (ret <= 0)
{
break;
}
#endif
len = strlen(cmd);
for( i = 0; i < len; ++i )
{
if(cmd[i] == '\n' || cmd[i] == '\r')
cmd[i] = '\0';
}
HandleConsoleInput(&g_localConsole, cmd);
}
m_isRunning = false;
return false;
}
示例6: ASSERT
bool cIsThread::Start(void)
{
ASSERT(m_Handle == NULL_HANDLE); // Has already started one thread?
#ifdef _WIN32
// Create the thread suspended, so that the mHandle variable is valid in the thread procedure
DWORD ThreadID = 0;
m_Handle = CreateThread(NULL, 0, thrExecute, this, CREATE_SUSPENDED, &ThreadID);
if (m_Handle == NULL)
{
LOGERROR("ERROR: Could not create thread \"%s\", GLE = %d!", m_ThreadName.c_str(), GetLastError());
return false;
}
ResumeThread(m_Handle);
#if defined(_DEBUG) && defined(_MSC_VER)
// Thread naming is available only in MSVC
if (!m_ThreadName.empty())
{
SetThreadName(ThreadID, m_ThreadName.c_str());
}
#endif // _DEBUG and _MSC_VER
#else // _WIN32
if (pthread_create(&m_Handle, NULL, thrExecute, this))
{
LOGERROR("ERROR: Could not create thread \"%s\", !", m_ThreadName.c_str());
return false;
}
#endif // else _WIN32
return true;
}
示例7: create_thread
void create_thread( ThreadData* td, bool dec_child = false )
{
// If the thread starts successfully, td will be deleted by thread_stub2.
// So we must save the threadName for later.
std::string threadName = td->name;
unsigned threadid = 0;
HANDLE h = (HANDLE)_beginthreadex( nullptr, 0, thread_stub2, td, 0, &threadid );
if ( h == 0 ) // added for better debugging
{
POLLOG.Format(
"error in create_thread: {:d} {:d} \"{:s}\" \"{:s}\" {:d} {:d} {:s} {:d} {:d} {:}\n" )
<< errno << _doserrno << strerror( errno ) << strerror( _doserrno ) << threads++
<< (unsigned)thread_stub2 << td->name.c_str() << (unsigned)td->entry
<< (unsigned)td->entry_noparam << td->arg;
// dec_child says that we should dec_child_threads when there's an error... :)
if ( dec_child )
--child_threads;
}
else
{
SetThreadName( threadid, threadName );
CloseHandle( h );
}
}
示例8: CreateThread
bool FRunnableThreadWin::CreateInternal(FRunnable* InRunnable, const TCHAR* InThreadName,
uint32 InStackSize,
EThreadPriority InThreadPri, uint64 InThreadAffinityMask)
{
Runnable = InRunnable;
ThreadAffinityMask = InThreadAffinityMask;
ThreadInitSyncEvent = FPlatformProcess::GetSynchEventFromPool(true);
Thread = CreateThread(NULL, InStackSize, _ThreadProc, this, STACK_SIZE_PARAM_IS_A_RESERVATION, (::DWORD *)&ThreadID);
if (Thread == nullptr)
{
Runnable = nullptr;
}
else
{
//FThreadManager::Get().AddThread(Thread , this);
//ThreadStartUp
ThreadInitSyncEvent->Wait(INFINITE);
ThreadName = InThreadName ? InThreadName : TEXT("Unnamed");
SetThreadName(ThreadID, ThreadName.c_str());
SetThreadPriority(InThreadPri);
}
FPlatformProcess::ReturnSynchEventToPool(ThreadInitSyncEvent);
ThreadInitSyncEvent = nullptr;
return Thread != NULL;
}
示例9: SetThreadName
void ObjectUpdaterThread::run()
{
SetThreadName("Object Updater - M%u|I%u", m_MapMgr->GetMapId(), m_MapMgr->GetInstanceID());
WOWD_THREAD_TRY_EXECUTION2
Do();
WOWD_THREAD_HANDLE_CRASH2
}
示例10: modem_input_thread
void modem_input_thread(void *args)
{
int rd;
int buffered;
size_t buffer;
BOOL monitor_dsr=TRUE;
SetThreadName("Modem Input");
conn_api.input_thread_running=1;
if(args != NULL) {
if((comGetModemStatus(com)&COM_DSR) == 0)
monitor_dsr=FALSE;
}
while(com != COM_HANDLE_INVALID && !conn_api.terminate) {
rd=comReadBuf(com, conn_api.rd_buf, conn_api.rd_buf_size, NULL, 100);
buffered=0;
while(buffered < rd) {
pthread_mutex_lock(&(conn_inbuf.mutex));
buffer=conn_buf_wait_free(&conn_inbuf, rd-buffered, 100);
buffered+=conn_buf_put(&conn_inbuf, conn_api.rd_buf+buffered, buffer);
pthread_mutex_unlock(&(conn_inbuf.mutex));
}
if(args==NULL) {
if((comGetModemStatus(com)&COM_DCD) == 0)
break;
}
else if(monitor_dsr) {
if((comGetModemStatus(com)&COM_DSR) == 0)
break;
}
}
if(args != NULL)
comLowerDTR(com);
conn_api.input_thread_running=0;
}
示例11: SetThreadName
bool Database::run()
{
SetThreadName("Database Execute Thread");
ThreadRunning = true;
char * query = queries_queue.pop();
DatabaseConnection * con = GetFreeConnection();
while(query)
{
_SendQuery( con, query, false );
SafeDeleteArray(query);
if(m_threadRunning == true)
break;
query = queries_queue.pop();
}
con->Busy.Release();
if(queries_queue.get_size() > 0)
{
// execute all the remaining queries
query = queries_queue.pop_nowait();
while(query)
{
DatabaseConnection * con = GetFreeConnection();
_SendQuery( con, query, false );
con->Busy.Release();
SafeDeleteArray(query);
query=queries_queue.pop_nowait();
}
}
ThreadRunning = false;
return false;
}
示例12: SetThreadName
bool SocketWorkerThread::run()
{
SetThreadName("Socket Worker");
HANDLE cp = sSocketMgr.GetCompletionPort();
DWORD len;
Socket * s;
OverlappedStruct * ov;
LPOVERLAPPED ol_ptr;
while(true)
{
#ifndef _WIN64
if(!GetQueuedCompletionStatus(cp, &len, (LPDWORD)&s, &ol_ptr, 10000))
#else
if(!GetQueuedCompletionStatus(cp, &len, (PULONG_PTR)&s, &ol_ptr, 10000))
#endif
continue;
ov = CONTAINING_RECORD(ol_ptr, OverlappedStruct, m_overlap);
if(ov->m_event == SOCKET_IO_THREAD_SHUTDOWN)
{
delete ov;
return true;
}
if(ov->m_event < NUM_SOCKET_IO_EVENTS)
ophandlers[ov->m_event](s, len);
}
return true;
}
示例13: defined
VOID CL_ThreadUnix::ExecRun()
{
#if defined (_FOR_ANDROID_) || defined (_FOR_APPLE_) || defined (_LINUX)
m_dwThreadID = GetCurrentThreadId();
#else
m_dwThreadID = (DWORD)m_tid;
#endif
#if defined(_LINUX)
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); // 允许退出线程
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); // 设置立即取消
#endif
SetPriorityNormal();
SetThreadName();
CL_Printf("<<<< Thread [%s] run (%lu, 0x%x) prio: %d, TC: %lu.", m_szThreadName, m_dwThreadID, m_dwThreadID, GetPriorityExt(), ::GetTickCount());
#ifdef _FOR_APPLE_
m_pPool = NULL;
pool_alloc(&m_pPool);
#endif
m_pThreadIF->Run();
#ifdef _FOR_APPLE_
pool_release(&m_pPool);
#endif
CL_Printf("<<<< Thread [%s] quit (%lu, 0x%x) TC: %lu.", m_szThreadName, m_dwThreadID, m_dwThreadID, ::GetTickCount());
m_isAlive = CL_FALSE;
m_dwThreadID = 0;
}
示例14: traiter
bool RenderThread::update()
{
/*
- Tant qu'il n'y a pas de command
-> je pop des task
- Une fois que j'ai mes commandes
-> pour chacunes d'elles
-> je regarde si c'est a moi de les traiter (ex : changement de scene)
-> si ca n'est pas a moi de les traiter
-> je les passe au render context actif
-> si il n'y a pas de render context actif, c'est que j'ai fait une erreur, et j'assert dans ta face :D
*/
_registerId();
_run = true;
_insideRun = true;
DWORD threadId = GetThreadId(static_cast<HANDLE>(_threadHandle.native_handle()));
SetThreadName(threadId, this->_name.c_str());
TMQ::MessageBase *task = nullptr;
while (_run && _insideRun)
{
SCOPE_profile_cpu_i("RenderTimer", "Update");
if (TMQ::TaskManager::RenderThreadGetTask(task))
{
SCOPE_profile_cpu_i("RenderTimer", "Execute task");
auto success = execute(task); // we receive a task that we cannot treat
AGE_ASSERT(success);
}
}
return true;
}
示例15: xcsncpy
VOID CL_ThreadUnix::ResetName(const XCHAR* name)
{
if (!name) return;
xcsncpy(m_szThreadName, name, CL_THREAD_NAME_LEN);
m_szThreadName[CL_THREAD_NAME_LEN - 1] = TEXT('\0');
SetThreadName();
}