本文整理汇总了C++中setCurrentThreadName函数的典型用法代码示例。如果您正苦于以下问题:C++ setCurrentThreadName函数的具体用法?C++ setCurrentThreadName怎么用?C++ setCurrentThreadName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setCurrentThreadName函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: setCurrentThreadName
unsigned int WINAPI ConsoleListener::RunThread(void *lpParam)
{
setCurrentThreadName("ConsoleThread");
ConsoleListener *consoleLog = (ConsoleListener *)lpParam;
consoleLog->LogWriterThread();
return 0;
}
开发者ID:MoonSnidget,项目名称:ppsspp,代码行数:7,代码来源:ConsoleListener.cpp
示例2: defined
VOID CL_ThreadUnix::SetThreadName()
{
#if defined (_LINUX)
// if thread is running do reset the running threadname
if (!m_tid) return;
// for task name length can be only 16 byte
char threadname[TASKNAME_COMLEN];
strncpy(threadname, m_szThreadName, TASKNAME_COMLEN);
threadname[TASKNAME_COMLEN - 1] = '\0';
if (pthread_setname_np(m_tid, threadname))
{
CL_PERROR("<<<< Set thread [%lu] [%s] name to [%s] failed : %s.", m_dwThreadID, m_szThreadName, threadname, strerror(errno));
}
else
{
CL_Printf("<<<< Set thread [%lu] [%s] name to [%s] TC : %lu.", m_dwThreadID, m_szThreadName, threadname, ::GetTickCount());
}
#elif defined(_FOR_ANDROID_)
if (m_dwThreadID != (DWORD)gettid())
{
CL_PERROR("<<<< Set thread [%s][%lu, 0x%x] name failed, NOT in current Thread.", m_szThreadName, m_dwThreadID, m_dwThreadID);
return;
}
prctl(PR_SET_NAME, (unsigned long) m_szThreadName, 0, 0, 0);
CL_Printf("<<<< Set thread [%s] (%lu, 0x%x) name TC: %lu.", m_szThreadName, m_dwThreadID, m_dwThreadID, ::GetTickCount());
#elif defined(_FOR_APPLE_)
if (m_dwThreadID != (DWORD)gettid())
{
CL_PERROR("<<<< Set thread [%s][%lu, 0x%x] name failed, NOT in current Thread.", m_szThreadName, m_dwThreadID, m_dwThreadID);
return;
}
setCurrentThreadName(m_szThreadName);
#endif
}
开发者ID:dongxiaozhen,项目名称:lbbNote,代码行数:34,代码来源:CL_ThreadUnix.cpp
示例3: EmuThreadFunc
static void EmuThreadFunc() {
JNIEnv *env;
gJvm->AttachCurrentThread(&env, nullptr);
setCurrentThreadName("Emu");
ILOG("Entering emu thread");
// Wait for render loop to get started.
if (!graphicsContext || !graphicsContext->Initialized()) {
ILOG("Runloop: Waiting for displayInit...");
while (!graphicsContext || !graphicsContext->Initialized()) {
sleep_ms(20);
}
} else {
ILOG("Runloop: Graphics context available! %p", graphicsContext);
}
NativeInitGraphics(graphicsContext);
ILOG("Graphics initialized. Entering loop.");
// There's no real requirement that NativeInit happen on this thread.
// We just call the update/render loop here.
emuThreadState = (int)EmuThreadState::RUNNING;
while (emuThreadState != (int)EmuThreadState::QUIT_REQUESTED) {
UpdateRunLoopAndroid(env);
}
emuThreadState = (int)EmuThreadState::STOPPED;
NativeShutdownGraphics();
gJvm->DetachCurrentThread();
ILOG("Leaving emu thread");
}
开发者ID:takashow,项目名称:ppsspp,代码行数:33,代码来源:app-android.cpp
示例4: Java_org_ppsspp_ppsspp_NativeRenderer_displayRender
// JavaEGL
extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayRender(JNIEnv *env, jobject obj) {
static bool hasSetThreadName = false;
if (!hasSetThreadName) {
hasSetThreadName = true;
setCurrentThreadName("AndroidRender");
}
if (renderer_inited) {
NativeUpdate();
NativeRender(graphicsContext);
time_update();
} else {
ELOG("BAD: Ended up in nativeRender even though app has quit.%s", "");
// Shouldn't really get here. Let's draw magenta.
// TODO: Should we have GL here?
glDepthMask(GL_TRUE);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClearColor(1.0, 0.0, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
}
std::lock_guard<std::mutex> guard(frameCommandLock);
if (!nativeActivity) {
while (!frameCommands.empty())
frameCommands.pop();
return;
}
// Still under lock here.
ProcessFrameCommands(env);
}
开发者ID:thesourcehim,项目名称:ppsspp,代码行数:32,代码来源:app-android.cpp
示例5: EmuThreadFunc
static void EmuThreadFunc() {
setCurrentThreadName("Emu");
while (true) {
switch ((EmuThreadState)emuThreadState) {
case EmuThreadState::START_REQUESTED:
emuThreadState = EmuThreadState::RUNNING;
/* fallthrough */
case EmuThreadState::RUNNING:
EmuFrame();
break;
case EmuThreadState::PAUSE_REQUESTED:
emuThreadState = EmuThreadState::PAUSED;
/* fallthrough */
case EmuThreadState::PAUSED:
sleep_ms(1);
break;
default:
case EmuThreadState::QUIT_REQUESTED:
emuThreadState = EmuThreadState::STOPPED;
ctx->StopThread();
return;
}
}
}
开发者ID:pal1000,项目名称:ppsspp,代码行数:25,代码来源:libretro.cpp
示例6: soundThread
unsigned int WINAPI soundThread(void *)
{
setCurrentThreadName("DSoundThread");
currentPos = 0;
lastPos = 0;
//writeDataToBuffer(0,realtimeBuffer,bufferSize);
// dsBuffer->Lock(0, bufferSize, (void **)&p1, &num1, (void **)&p2, &num2, 0);
dsBuffer->Play(0,0,DSBPLAY_LOOPING);
while (!threadData)
{
EnterCriticalSection(&soundCriticalSection);
dsBuffer->GetCurrentPosition((DWORD *)¤tPos, 0);
int numBytesToRender = RoundDown128(ModBufferSize(currentPos - lastPos));
if (numBytesToRender >= 256)
{
int numBytesRendered = 4 * (*callback)(realtimeBuffer, numBytesToRender >> 2, 16, 44100, 2);
//We need to copy the full buffer, regardless of what the mixer claims to have filled
//If we don't do this then the sound will loop if the sound stops and the mixer writes only zeroes
numBytesRendered = numBytesToRender;
writeDataToBuffer(lastPos, (char *) realtimeBuffer, numBytesRendered);
currentPos = ModBufferSize(lastPos + numBytesRendered);
totalRenderedBytes += numBytesRendered;
lastPos = currentPos;
}
LeaveCriticalSection(&soundCriticalSection);
WaitForSingleObject(soundSyncEvent, MAXWAIT);
}
开发者ID:18859966862,项目名称:ppsspp,代码行数:34,代码来源:DSoundStream.cpp
示例7: setCurrentThreadName
// TODO: Move the init into the thread, like WASAPI?
int DSoundAudioBackend::RunThread() {
setCurrentThreadName("DSound");
currentPos_ = 0;
lastPos_ = 0;
dsBuffer_->Play(0,0,DSBPLAY_LOOPING);
while (!threadData_) {
EnterCriticalSection(&soundCriticalSection);
dsBuffer_->GetCurrentPosition((DWORD *)¤tPos_, 0);
int numBytesToRender = RoundDown128(ModBufferSize(currentPos_ - lastPos_));
if (numBytesToRender >= 256) {
int numBytesRendered = 4 * (*callback_)(realtimeBuffer_, numBytesToRender >> 2, 16, 44100, 2);
//We need to copy the full buffer, regardless of what the mixer claims to have filled
//If we don't do this then the sound will loop if the sound stops and the mixer writes only zeroes
numBytesRendered = numBytesToRender;
WriteDataToBuffer(lastPos_, (char *) realtimeBuffer_, numBytesRendered);
currentPos_ = ModBufferSize(lastPos_ + numBytesRendered);
totalRenderedBytes_ += numBytesRendered;
lastPos_ = currentPos_;
}
LeaveCriticalSection(&soundCriticalSection);
WaitForSingleObject(soundSyncEvent_, MAXWAIT);
}
开发者ID:chinhodado,项目名称:ppsspp,代码行数:30,代码来源:DSoundStream.cpp
示例8: setCurrentThreadName
void COLD AsyncJobRouterController::start() {
//Lambdas rock
childThread = new std::thread([](void* ctx, Tablespace& tablespace) {
setCurrentThreadName("Yak job router");
AsyncJobRouter worker(ctx, tablespace);
while(worker.processNextRequest()) {
//Loop until stop msg is received (--> processNextRequest() returns false)
}
}, ctx, std::ref(tablespace));
}
开发者ID:ulikoehler,项目名称:YakDB,代码行数:10,代码来源:AsyncJobRouter.cpp
示例9: setCurrentThreadName
//==============================================================================
void Thread::threadEntryPoint()
{
if (!threadName.empty ())
setCurrentThreadName (threadName);
if (startSuspensionEvent.wait (10000))
run();
closeThreadHandle();
}
开发者ID:bachase,项目名称:rippled,代码行数:11,代码来源:Thread.cpp
示例10: CreateEvent
int DSoundAudioBackend::RunThread() {
if (FAILED(DirectSoundCreate8(0, &ds_, 0))) {
ds_ = NULL;
threadData_ = 2;
return 1;
}
ds_->SetCooperativeLevel(window_, DSSCL_PRIORITY);
if (!CreateBuffer()) {
ds_->Release();
ds_ = NULL;
threadData_ = 2;
return 1;
}
soundSyncEvent_ = CreateEvent(0, false, false, 0);
InitializeCriticalSection(&soundCriticalSection);
DWORD num1;
short *p1;
dsBuffer_->Lock(0, bufferSize_, (void **)&p1, &num1, 0, 0, 0);
memset(p1, 0, num1);
dsBuffer_->Unlock(p1, num1, 0, 0);
totalRenderedBytes_ = -bufferSize_;
setCurrentThreadName("DSound");
currentPos_ = 0;
lastPos_ = 0;
dsBuffer_->Play(0,0,DSBPLAY_LOOPING);
while (!threadData_) {
EnterCriticalSection(&soundCriticalSection);
dsBuffer_->GetCurrentPosition((DWORD *)¤tPos_, 0);
int numBytesToRender = RoundDown128(ModBufferSize(currentPos_ - lastPos_));
if (numBytesToRender >= 256) {
int numBytesRendered = 4 * (*callback_)(realtimeBuffer_, numBytesToRender >> 2, 16, 44100, 2);
//We need to copy the full buffer, regardless of what the mixer claims to have filled
//If we don't do this then the sound will loop if the sound stops and the mixer writes only zeroes
numBytesRendered = numBytesToRender;
WriteDataToBuffer(lastPos_, (char *) realtimeBuffer_, numBytesRendered);
currentPos_ = ModBufferSize(lastPos_ + numBytesRendered);
totalRenderedBytes_ += numBytesRendered;
lastPos_ = currentPos_;
}
LeaveCriticalSection(&soundCriticalSection);
WaitForSingleObject(soundSyncEvent_, MAXWAIT);
}
开发者ID:njh08d,项目名称:ppsspp,代码行数:55,代码来源:DSoundStream.cpp
示例11: CPU_RunLoop
void CPU_RunLoop() {
setCurrentThreadName("CPU");
FPU_SetFastMode();
if (CPU_NextState(CPU_THREAD_PENDING, CPU_THREAD_STARTING)) {
CPU_Init();
CPU_NextState(CPU_THREAD_STARTING, CPU_THREAD_RUNNING);
} else if (!CPU_NextState(CPU_THREAD_RESUME, CPU_THREAD_RUNNING)) {
ERROR_LOG(CPU, "CPU thread in unexpected state: %d", cpuThreadState);
return;
}
while (cpuThreadState != CPU_THREAD_SHUTDOWN)
{
CPU_WaitStatus(cpuThreadCond, &CPU_HasPendingAction);
switch (cpuThreadState) {
case CPU_THREAD_EXECUTE:
mipsr4k.RunLoopUntil(cpuThreadUntil);
gpu->FinishEventLoop();
CPU_NextState(CPU_THREAD_EXECUTE, CPU_THREAD_RUNNING);
break;
// These are fine, just keep looping.
case CPU_THREAD_RUNNING:
case CPU_THREAD_SHUTDOWN:
break;
case CPU_THREAD_QUIT:
// Just leave the thread, CPU is switching off thread.
CPU_SetState(CPU_THREAD_NOT_RUNNING);
return;
default:
ERROR_LOG(CPU, "CPU thread in unexpected state: %d", cpuThreadState);
// Begin shutdown, otherwise we'd just spin on this bad state.
CPU_SetState(CPU_THREAD_SHUTDOWN);
break;
}
}
if (coreState != CORE_ERROR) {
coreState = CORE_POWERDOWN;
}
// Let's make sure the gpu has already cleaned up before we start freeing memory.
if (gpu) {
gpu->FinishEventLoop();
gpu->SyncThread(true);
}
CPU_Shutdown();
CPU_SetState(CPU_THREAD_NOT_RUNNING);
}
开发者ID:blacklin,项目名称:ppsspp,代码行数:53,代码来源:System.cpp
示例12: Java_org_ppsspp_ppsspp_NativeRenderer_displayRender
extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayRender(JNIEnv *env, jobject obj) {
static bool hasSetThreadName = false;
if (!hasSetThreadName) {
hasSetThreadName = true;
setCurrentThreadName("AndroidRender");
}
if (renderer_inited) {
// TODO: Look into if these locks are a perf loss
{
lock_guard guard(input_state.lock);
input_state.pad_lstick_x = left_joystick_x_async;
input_state.pad_lstick_y = left_joystick_y_async;
input_state.pad_rstick_x = right_joystick_x_async;
input_state.pad_rstick_y = right_joystick_y_async;
UpdateInputState(&input_state);
}
NativeUpdate(input_state);
{
lock_guard guard(input_state.lock);
EndInputState(&input_state);
}
NativeRender();
time_update();
} else {
ELOG("BAD: Ended up in nativeRender even though app has quit.%s", "");
// Shouldn't really get here. Let's draw magenta.
glDepthMask(GL_TRUE);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClearColor(1.0, 0.0, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
}
lock_guard guard(frameCommandLock);
while (!frameCommands.empty()) {
FrameCommand frameCmd;
frameCmd = frameCommands.front();
frameCommands.pop();
DLOG("frameCommand %s %s", frameCmd.command.c_str(), frameCmd.params.c_str());
jstring cmd = env->NewStringUTF(frameCmd.command.c_str());
jstring param = env->NewStringUTF(frameCmd.params.c_str());
env->CallVoidMethod(obj, postCommand, cmd, param);
env->DeleteLocalRef(cmd);
env->DeleteLocalRef(param);
}
}
开发者ID:jrancher,项目名称:ppsspp,代码行数:52,代码来源:app-android.cpp
示例13: Java_org_ppsspp_ppsspp_NativeRenderer_displayRender
extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayRender(JNIEnv *env, jobject obj) {
static bool hasSetThreadName = false;
if (!hasSetThreadName) {
hasSetThreadName = true;
setCurrentThreadName("AndroidRender");
}
if (useCPUThread) {
// This is the "GPU thread".
graphicsContext->ThreadFrame();
} else {
UpdateRunLoopAndroid(env);
}
}
开发者ID:takashow,项目名称:ppsspp,代码行数:14,代码来源:app-android.cpp
示例14: EmuThreadFunc
static void EmuThreadFunc(GraphicsContext *graphicsContext) {
setCurrentThreadName("Emu");
// There's no real requirement that NativeInit happen on this thread.
// We just call the update/render loop here.
emuThreadState = (int)EmuThreadState::RUNNING;
NativeInitGraphics(graphicsContext);
while (emuThreadState != (int)EmuThreadState::QUIT_REQUESTED) {
UpdateRunLoop();
}
emuThreadState = (int)EmuThreadState::STOPPED;
NativeShutdownGraphics();
}
开发者ID:takashow,项目名称:ppsspp,代码行数:16,代码来源:SDLMain.cpp
示例15: Java_org_ppsspp_ppsspp_NativeRenderer_displayRender
// JavaEGL
extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayRender(JNIEnv *env, jobject obj) {
static bool hasSetThreadName = false;
if (!hasSetThreadName) {
hasSetThreadName = true;
setCurrentThreadName("AndroidRender");
}
if (renderer_inited) {
// TODO: Look into if these locks are a perf loss
{
lock_guard guard(input_state.lock);
input_state.pad_lstick_x = left_joystick_x_async;
input_state.pad_lstick_y = left_joystick_y_async;
input_state.pad_rstick_x = right_joystick_x_async;
input_state.pad_rstick_y = right_joystick_y_async;
UpdateInputState(&input_state);
}
NativeUpdate(input_state);
{
lock_guard guard(input_state.lock);
EndInputState(&input_state);
}
NativeRender(graphicsContext);
time_update();
} else {
ELOG("BAD: Ended up in nativeRender even though app has quit.%s", "");
// Shouldn't really get here. Let's draw magenta.
// TODO: Should we have GL here?
glDepthMask(GL_TRUE);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClearColor(1.0, 0.0, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
}
lock_guard guard(frameCommandLock);
if (!nativeActivity) {
while (!frameCommands.empty())
frameCommands.pop();
return;
}
ProcessFrameCommands(env);
}
开发者ID:njh08d,项目名称:ppsspp,代码行数:48,代码来源:app-android.cpp
示例16: RunInputThread
static void RunInputThread() {
setCurrentThreadName("Input");
// NOTE: The keyboard and mouse buttons are handled via raw input, not here.
// This is mainly for controllers which need to be polled, instead of generating events.
while (inputThreadEnabled) {
ExecuteInputPoll();
// Try to update 250 times per second.
Sleep(4);
}
lock_guard guard(inputMutex);
inputThreadStatus = false;
inputEndCond.notify_one();
}
开发者ID:AdmiralCurtiss,项目名称:ppsspp,代码行数:17,代码来源:InputDevice.cpp
示例17: setCurrentThreadName
void VulkanRenderManager::ThreadFunc() {
setCurrentThreadName("RenderMan");
int threadFrame = threadInitFrame_;
bool nextFrame = false;
bool firstFrame = true;
while (true) {
{
if (nextFrame) {
threadFrame++;
if (threadFrame >= vulkan_->GetInflightFrames())
threadFrame = 0;
}
FrameData &frameData = frameData_[threadFrame];
std::unique_lock<std::mutex> lock(frameData.pull_mutex);
while (!frameData.readyForRun && run_) {
VLOG("PULL: Waiting for frame[%d].readyForRun", threadFrame);
frameData.pull_condVar.wait(lock);
}
if (!frameData.readyForRun && !run_) {
// This means we're out of frames to render and run_ is false, so bail.
break;
}
VLOG("PULL: frame[%d].readyForRun = false", threadFrame);
frameData.readyForRun = false;
// Previously we had a quick exit here that avoided calling Run() if run_ was suddenly false,
// but that created a race condition where frames could end up not finished properly on resize etc.
// Only increment next time if we're done.
nextFrame = frameData.type == VKRRunType::END;
assert(frameData.type == VKRRunType::END || frameData.type == VKRRunType::SYNC);
}
VLOG("PULL: Running frame %d", threadFrame);
if (firstFrame) {
ILOG("Running first frame (%d)", threadFrame);
firstFrame = false;
}
Run(threadFrame);
VLOG("PULL: Finished frame %d", threadFrame);
}
// Wait for the device to be done with everything, before tearing stuff down.
vkDeviceWaitIdle(vulkan_->GetDevice());
VLOG("PULL: Quitting");
}
开发者ID:takashow,项目名称:ppsspp,代码行数:45,代码来源:VulkanRenderManager.cpp
示例18: currentThreadHolder
void Thread::threadEntryPoint()
{
const CurrentThreadHolder::Ptr currentThreadHolder (getCurrentThreadHolder());
currentThreadHolder->value = this;
if (threadName.isNotEmpty())
setCurrentThreadName (threadName);
if (startSuspensionEvent.wait (10000))
{
bassert (getCurrentThreadId() == threadId);
if (affinityMask != 0)
setCurrentThreadAffinityMask (affinityMask);
run();
}
currentThreadHolder->value.releaseCurrentThreadStorage();
closeThreadHandle();
}
开发者ID:619213152,项目名称:vpal20,代码行数:21,代码来源:Thread.cpp
示例19: CalculateCRCThread
static int CalculateCRCThread() {
setCurrentThreadName("ReportCRC");
// TODO: Use the blockDevice from pspFileSystem?
FileLoader *fileLoader = ConstructFileLoader(crcFilename);
BlockDevice *blockDevice = constructBlockDevice(fileLoader);
u32 crc = 0;
if (blockDevice) {
crc = blockDevice->CalculateCRC();
}
delete blockDevice;
delete fileLoader;
lock_guard guard(crcLock);
crcResults[crcFilename] = crc;
crcCond.notify_one();
return 0;
}
开发者ID:makotech222,项目名称:ppsspp,代码行数:21,代码来源:Reporting.cpp
示例20: CPU_RunLoop
void CPU_RunLoop() {
setCurrentThreadName("CPUThread");
if (!CPU_NextState(CPU_THREAD_PENDING, CPU_THREAD_STARTING)) {
ERROR_LOG(CPU, "CPU thread in unexpected state: %d", cpuThreadState);
return;
}
CPU_Init();
CPU_NextState(CPU_THREAD_STARTING, CPU_THREAD_RUNNING);
while (cpuThreadState != CPU_THREAD_SHUTDOWN)
{
CPU_WaitStatus(&CPU_HasPendingAction);
switch (cpuThreadState) {
case CPU_THREAD_EXECUTE:
mipsr4k.RunLoopUntil(cpuThreadUntil);
gpu->FinishEventLoop();
CPU_NextState(CPU_THREAD_EXECUTE, CPU_THREAD_RUNNING);
break;
// These are fine, just keep looping.
case CPU_THREAD_RUNNING:
case CPU_THREAD_SHUTDOWN:
break;
default:
ERROR_LOG(CPU, "CPU thread in unexpected state: %d", cpuThreadState);
// Begin shutdown, otherwise we'd just spin on this bad state.
CPU_SetState(CPU_THREAD_SHUTDOWN);
break;
}
}
if (coreState != CORE_ERROR) {
coreState = CORE_POWERDOWN;
}
CPU_Shutdown();
CPU_SetState(CPU_THREAD_NOT_RUNNING);
}
开发者ID:GustavoFalleiros,项目名称:ppsspp,代码行数:40,代码来源:System.cpp
注:本文中的setCurrentThreadName函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论