当前位置: 首页>>代码示例>>C++>>正文


C++ GetThreadId函数代码示例

本文整理汇总了C++中GetThreadId函数的典型用法代码示例。如果您正苦于以下问题:C++ GetThreadId函数的具体用法?C++ GetThreadId怎么用?C++ GetThreadId使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetThreadId函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: poweroffInit

int poweroffInit()
{
	int res;
	static int _init_count = -1;

	if(_init_count == _iop_reboot_count)
		return 0;
	_init_count = _iop_reboot_count;

	while(((res = SifBindRpc(&cd0, PWROFF_IRX, 0)) >= 0) && (cd0.server == NULL))
		nopdelay();

	ee_thread_t thread;
	ee_thread_status_t thisThread;

	ee_sema_t sema;

	// Terminate and delete any previously created threads
	if (powerOffThreadId >= 0) {
		TerminateThread(powerOffThreadId);
		DeleteThread(powerOffThreadId);
		powerOffThreadId = -1;
	}

	// Delete any previously created semaphores
	if (PowerOffSema >= 0)
	{
		DeleteSema(PowerOffSema);
		PowerOffSema = -1;
	}

	sema.init_count = 0;
	sema.max_count = 1;
	sema.option = 0;
	PowerOffSema = CreateSema(&sema);

	ReferThreadStatus(GetThreadId(), &thisThread);

	if (thisThread.current_priority == 0) {
		ChangeThreadPriority(GetThreadId(), 51);
		thread.initial_priority = 50;
	} else
		thread.initial_priority = thisThread.current_priority - 1;

	thread.stack_size = 512 * 16;
	thread.gp_reg = &_gp;
	thread.func = PowerOffThread;
	thread.stack = (void *)poffThreadStack;
	powerOffThreadId = CreateThread(&thread);
	StartThread(powerOffThreadId, NULL);
	
	DIntr();
	SifAddCmdHandler(POFF_SIF_CMD, _poff_intr_callback, NULL);
	EIntr();

	int autoShutdown = 0;
	SifCallRpc(&cd0, PWROFF_ENABLE_AUTO_SHUTOFF, 0, NULL, 0, &autoShutdown, sizeof(autoShutdown), 0, 0);
	
	return res;
}
开发者ID:EvertonSilva,项目名称:ps2sdk,代码行数:60,代码来源:poweroff.c

示例2: thrd_equal

int thrd_equal(thrd_t thr0, thrd_t thr1)
{
#if defined(_TTHREAD_WIN32_)
  return GetThreadId(thr0) == GetThreadId(thr1);
#else
  return pthread_equal(thr0, thr1);
#endif
}
开发者ID:mrwicked,项目名称:tinycthread,代码行数:8,代码来源:tinycthread.c

示例3: unabto_thread_equal

int unabto_thread_equal(unabto_thread_t thread1, unabto_thread_t thread2)
{
#ifdef WIN32
    return GetThreadId(thread1) == GetThreadId(thread2);
#else
    return pthread_equal(thread1, thread2);
#endif
}
开发者ID:BridgeHill,项目名称:unabto,代码行数:8,代码来源:unabto_thread.c

示例4: embb_thread_equal

int embb_thread_equal(const embb_thread_t* lhs, const embb_thread_t* rhs) {
  embb_thread_id_t idLhs = GetThreadId(lhs->embb_internal_handle);
  embb_thread_id_t idRhs = GetThreadId(rhs->embb_internal_handle);
  if (idLhs == idRhs) {
    return 1;
  }
  return 0;
}
开发者ID:danklmn,项目名称:embb,代码行数:8,代码来源:thread.c

示例5: SetThreadName

int DeviceManagerThread::Run()
{
    ThreadCommand::PopBuffer command;

    SetThreadName("OVR::DeviceManagerThread");
    LogText("OVR::DeviceManagerThread - running (ThreadId=%p).\n", GetThreadId());
    

    while(!IsExiting())
    {
        // PopCommand will reset event on empty queue.
        if (PopCommand(&command))
        {
            command.Execute();
        }
        else
        {
            bool commands = 0;
            do
            {
                int n = poll(&PollFds[0], PollFds.GetSize(), -1);

                for (int i = 0; i < PollFds.GetSize(); i++)
                {
                    if (PollFds[i].revents & POLLERR)
                    {
                        OVR_DEBUG_LOG(("poll: error on [%d]: %d", i, PollFds[i].fd));
                    }
                    else if (PollFds[i].revents & POLLIN)
                    {
                        if (FdNotifiers[i])
                            FdNotifiers[i]->OnEvent(i, PollFds[i].fd);
                        else if (i == 0) // command
                        {
                            char dummy[128];                            
                            read(PollFds[i].fd, dummy, 128);
                            commands = 1;
                        }
                    }

                    if (PollFds[i].revents & POLLHUP)
                        PollFds[i].events = 0;

                    if (PollFds[i].revents != 0)
                    {
                        n--;
                        if (n == 0)
                            break;
                    }
                }                    
            } while (PollFds.GetSize() > 0 && !commands);
        }
    }

    LogText("OVR::DeviceManagerThread - exiting (ThreadId=%p).\n", GetThreadId());
    return 0;
}
开发者ID:BigRobCoder,项目名称:ohmd-plugin,代码行数:57,代码来源:OVR_Linux_DeviceManager.cpp

示例6: gsiEnterCriticalSection

void gsiEnterCriticalSection(GSICriticalSection *theCrit) 
{ 
	// If we're not already in it, wait for it
	if (GetThreadId() != theCrit->mOwnerThread)
	{
		gsiWaitForSemaphore(theCrit->mSemaphore, 0);
		theCrit->mOwnerThread = GetThreadId();
	}

	// Increment entry count
	theCrit->mEntryCount++;
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:12,代码来源:gsThreadPs2.c

示例7: sys_arch_sem_wait

u32_t
sys_arch_sem_wait(sys_sem_t Sema,u32_t u32Timeout)
{

	//Wait u32Timeout msec for the Sema to receive a signal.

	dbgprintf("sys_arch_sem_wait: Sema: %d, Timeout: %x (TID: %d)\n",Sema,u32Timeout,GetThreadId());

	if(u32Timeout==0)
	{

		//Wait with no timeouts.

		return	WaitSema(Sema)==0 ? 0:SYS_ARCH_TIMEOUT;
	}
	else if(u32Timeout==1)
	{

		//Poll.

		return	PollSema(Sema)==0 ? 0:SYS_ARCH_TIMEOUT;
	}
	else
	{

		//Use alarm to timeout.

		iop_sys_clock_t	ClockTicks;
		iop_sys_clock_t	Start;
		iop_sys_clock_t	End;
		int					iPID=GetThreadId();
		u32_t					u32WaitTime;

		GetSystemTime(&Start);
		USec2SysClock(u32Timeout*1000,&ClockTicks);
		SetAlarm(&ClockTicks,TimeoutHandler,(void*)iPID);

		if(WaitSema(Sema)!=0)
		{
			return	SYS_ARCH_TIMEOUT;
		}
		CancelAlarm(TimeoutHandler,(void*)iPID);
		GetSystemTime(&End);

		u32WaitTime=ComputeTimeDiff(&Start,&End);
		return	u32WaitTime<=u32Timeout ? u32WaitTime:u32Timeout;
	}
}
开发者ID:AzagraMac,项目名称:PS2_SDK,代码行数:48,代码来源:sys_arch.c

示例8: sys_sem_signal

void
sys_sem_signal(sys_sem_t Sema)
{
	dbgprintf("sys_sem_signal: Sema: %d (TID: %d)\n",Sema,GetThreadId());

	SignalSema(Sema);
}
开发者ID:AzagraMac,项目名称:PS2_SDK,代码行数:7,代码来源:sys_arch.c

示例9: Connect

bool CAsynPipe::Connect(const CAddress& Address)
{
	m_eState = eAPS_Connecting;
	CPipeThread* pThread = CPipeThreadMgr::Inst()->GetThread(GetThreadId());
	(new(pThread) CPipeConnectJob(GetLocalID(), Address, pThread))->Add(pThread);
	return true;
}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:7,代码来源:CAsynPipe.cpp

示例10: updatePos_exec

void RankSystem::updatePos_init(RankStats* rr, Stats* s, bool sync)
{
	if(rr == NULL)	// Verify Pointer to RankStats
		return;

	if(s != NULL)	// NULL Stats Update (Only for Synchronization)
		rr->addStats(s);

	if(sync == true)
		updatePos_exec(rr);
	else
	{
		// Prevent Waiting on MAIN Thread
		HANDLE h_temp = CreateThread(NULL, 0, updatePos_thread, rr, CREATE_SUSPENDED, NULL);
		if(h_temp == NULL)
		{
			MF_SyncLog("updatePos_init: Couldn't create thread for updating Ranks");
		}
		else
		{
#ifdef _DEBUG
			MF_SyncLog("updatePos_init: Creating Thread #%d", GetThreadId(h_temp));
#endif
			SetThreadPriority(h_temp, THREAD_PRIORITY_LOWEST);
			ResumeThread(h_temp);
			CloseHandle(h_temp);
		}
	}
}
开发者ID:souvikdas95,项目名称:CSX_AMXX_UPDATING,代码行数:29,代码来源:CRank.cpp

示例11: rmInit

void rmInit() {
	gsGlobal = gsKit_init_global();

	rm_mode_table[RM_VMODE_AUTO].mode = gsGlobal->Mode;
	rm_mode_table[RM_VMODE_AUTO].height = gsGlobal->Height;

	dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
				D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);

	// Initialize the DMAC
	dmaKit_chan_init(DMA_CHANNEL_GIF);

	rmSetMode(1);

	order = 0;

	aspectWidth = 1.0f;
	aspectHeight = 1.0f;

	shiftYVal = 1.0f;
	shiftY = &shiftYFunc;

	transX = 0.0f;
	transY = 0.0f;

	guiThreadID = GetThreadId();
	gsKit_add_vsync_handler(&rmOnVSync);
}
开发者ID:doctorxyz,项目名称:open-ps2-loader,代码行数:28,代码来源:renderman.c

示例12: thrd_is_current

int thrd_is_current(thrd_t thr) {
#if defined(_TTHREAD_WIN32_)
	return GetThreadId(thr) == GetCurrentThreadId();
#else	
	return (pthread_self() == thr);
#endif
}
开发者ID:Lionel-Coding-Lee,项目名称:libserdes,代码行数:7,代码来源:tinycthread.c

示例13: fileXio_Thread

void fileXio_Thread(void* param)
{
	int OldState;

	printf("fileXio: fileXio RPC Server v1.00\nCopyright (c) 2003 adresd\n");
	#ifdef DEBUG
		printf("fileXio: RPC Initialize\n");
	#endif

	SifInitRpc(0);

	RWBufferSize=DEFAULT_RWSIZE;
	CpuSuspendIntr(&OldState);
	rwbuf = AllocSysMemory(ALLOC_FIRST, RWBufferSize, NULL);
	CpuResumeIntr(OldState);
	if (rwbuf == NULL)
	{
		#ifdef DEBUG
  			printf("Failed to allocate memory for RW buffer!\n");
		#endif

		SleepThread();
	}

	SifSetRpcQueue(&qd, GetThreadId());
	SifRegisterRpc(&sd0, FILEXIO_IRX, &fileXio_rpc_server, fileXio_rpc_buffer, NULL, NULL, &qd);
	SifRpcLoop(&qd);
}
开发者ID:AKuHAK2,项目名称:ps2sdk,代码行数:28,代码来源:fileXio_iop.c

示例14: log_init_thread

void log_init_thread()
{
	if (!logger_attached)
		return;
	LPCWSTR pipeName = L"\\\\.\\pipe\\flog_server";
	for (;;)
	{
		hLoggerPipe = CreateFileW(pipeName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
		if (hLoggerPipe == INVALID_HANDLE_VALUE)
		{
			/* Non critical error code, just wait and try connecting again */
			if (GetLastError() != ERROR_PIPE_BUSY || !WaitNamedPipeW(pipeName, NMPWAIT_WAIT_FOREVER))
			{
				logger_attached = 0;
				break;
			}
			continue;
		}
		/* Send initial request */
		struct request request;
		request.magic = PROTOCOL_MAGIC;
		request.version = PROTOCOL_VERSION;
		request.pid = GetProcessId(GetCurrentProcess());
		request.tid = GetThreadId(GetCurrentThread());
		DWORD written;
		if (!WriteFile(hLoggerPipe, &request, sizeof(request), &written, NULL))
		{
			CloseHandle(hLoggerPipe);
			logger_attached = 0;
		}
		break;
	}
}
开发者ID:mt206,项目名称:flinux,代码行数:33,代码来源:log.c

示例15: InitThread

int InitThread(void)
{
	ee_sema_t sema;
	ee_thread_t thread;

	sema.max_count = 255;
	sema.init_count = 0;
	sema.option = (u32)"KernelTopThread";
	if((topSema = CreateSema(&sema)) < 0)
		return -1;

	thread.func = &topThread;
	thread.stack = stack;
	thread.stack_size = sizeof(stack);
	thread.gp_reg = &_gp;
	thread.option = (u32)"KernelTopThread";
	thread.initial_priority = 0;
	if((topId = CreateThread(&thread)) < 0)
	{
		DeleteSema(topSema);
		return -1;
	}

	topArg.requestOut = 0;
	topArg.requestIn = 0;
	StartThread(topId, &topArg);

	ChangeThreadPriority(GetThreadId(), 1);

	return topId;
}
开发者ID:AKuHAK,项目名称:ps2sdk,代码行数:31,代码来源:thread.c


注:本文中的GetThreadId函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。