本文整理汇总了C++中SleepThread函数的典型用法代码示例。如果您正苦于以下问题:C++ SleepThread函数的具体用法?C++ SleepThread怎么用?C++ SleepThread使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SleepThread函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadmodules
void loadmodules(int free)
{
s32 ret;
if(free == 1)
{
if((ret = SifLoadModule("host0:freesio2.irx", 0, NULL)) < 0)
{
printf("Failed to load freesio2.irx module (%d)\n", ret);
SleepThread();
}
if((ret = SifLoadModule("host0:freepad.irx", 0, NULL)) < 0)
{
printf("Failed to load freepad.irx module (%d)\n", ret);
SleepThread();
}
}
else
{
if((ret = SifLoadModule("rom0:XSIO2MAN", 0, NULL)) < 0)
{
printf("Failed to load XSIO2MAN module (%d)\n", ret);
SleepThread();
}
if((ret = SifLoadModule("rom0:XPADMAN", 0, NULL)) < 0)
{
printf("Failed to load XPADMAN module (%d)\n", ret);
SleepThread();
}
}
}
示例2: loadModules
static void loadModules(void)
{
int ret;
#ifdef ROM_PADMAN
ret = SifLoadModule("rom0:SIO2MAN", 0, NULL);
#else
ret = SifLoadModule("rom0:XSIO2MAN", 0, NULL);
#endif
if (ret < 0) {
SleepThread();
}
ret = SifLoadModule("rom0:CDVDMAN", 0, NULL);
if(ret < 0) {
SleepThread();
}
#ifdef ROM_PADMAN
ret = SifLoadModule("rom0:PADMAN", 0, NULL);
#else
ret = SifLoadModule("rom0:XPADMAN", 0, NULL);
#endif
if (ret < 0) {
SleepThread();
}
}
示例3: main
int main(void)
{
int ret;
/* Load LibSD (freesd will work too one day, I promise ;) */
ret = SifLoadModule("host:LIBSD.IRX", 0, NULL);
if (ret<0)
{
printf("XXXXX failed to load host:LIBSD.IRX (%d)\n", ret);
SleepThread();
}
/* Load ps2snd */
ret = SifLoadModule("host:ps2snd.irx", 0, NULL);
if (ret<0)
{
printf("XXXXX failed to load host:ps2snd.irx (%d)\n", ret);
SleepThread();
}
/* Start LibSD */
if (sceSdInit(0)<0)
{
printf("Failed to start LibSD\n");
SleepThread();
}
/* Setup master volumes for both cores */
sceSdSetParam(0 | SD_PARAM_MVOLL, 0x3fff);
sceSdSetParam(0 | SD_PARAM_MVOLR, 0x3fff);
sceSdSetParam(1 | SD_PARAM_MVOLL, 0x3fff);
sceSdSetParam(1 | SD_PARAM_MVOLR, 0x3fff);
/*
Open a stream, using voices 0:22 and 0:23
It's stereo and it should be closed when the end is hit.
The SPU buffers are at 0x6000 in spu2 ram.
The chunksize is 1024 blocks (16kbyte)
*/
if (sndStreamOpen("host:stream.adpcm", SD_VOICE(0,22) | (SD_VOICE(0,23)<<16), STREAM_STEREO | STREAM_END_CLOSE, 0x6000, 1024)<0)
{
printf("Failed to open stream\n");
SleepThread();
}
sndStreamPlay();
SleepThread();
return(0);
}
示例4: ResetEvent
// 注册线程
void CDlgAutoRegister::Run()
{
ResetEvent(m_hEventTheadNoRun1);
::CoInitialize(NULL);
int nStart = GetSeconds(m_config.m_startTime);
int nLast = GetSeconds(m_config.m_endTime);
while(1)
{
int nCurrent = (int)time(NULL);
// if (nCurrent > nLast)
// {
// PostMessage(M_TASK_OVER);
// SetEvent(m_hEventTheadNoRun1);
// ::CoUninitialize();
// return;
// }
try
{
if (nCurrent >= nStart)
{
int n = m_arrayTasks.size();
for (int i = 0; i < (int)m_arrayTasks.size(); i++)
{
TaskNode& task = m_arrayTasks[i];
//Sleep(task.nDeltaSeconds S);
SleepThread(task.nDeltaSeconds, 1);
RegisterID(task);
}
::CoUninitialize();
PostMessage(M_TASK_OVER);
SetEvent(m_hEventTheadNoRun1);
return ;
}
}
catch(...)
{
IBA_LOG0(_T("出现异常1"));
}
//Sleep(1 S);
SleepThread(1,1);
}
::CoUninitialize();
PostMessage(M_TASK_OVER);
SetEvent(m_hEventTheadNoRun1);
}
示例5: ExecGame
void ExecGame(void)
{
int i;
scr_printf(" Installing Engine...\n");
u32 EngineStore = 0x80080000;
u32 EngineRead = (void*)Engine;
for (i = 0; i < sizeof(Engine); i += 4)
{
//scr_printf("A");
ee_kmode_enter();
*(u32*)EngineStore = *(u32*)EngineRead;
ee_kmode_exit();
EngineStore += 4;
EngineRead += 4;
}
ee_kmode_enter();
*(u32*)0x80081000 = 0x80081010; //Writes the initial storage of the codes
ee_kmode_exit();
waitCdReady();
scr_printf(" Loading...\n");
//for (a = 0; a < 40000000; a++)
{
}
if(strlen(bootFileName = parseSystemCnf()) <= 0)
{
scr_printf(" == Fatal Error ==\n");
SleepThread();
}
scr_printf("\n Loaded Game!\n");
u32 HookValue = (0x00080000 / 4) + 0x0C000000;
padPortClose(0, 0);
//scr_printf(" Shut down PAD, shutting down RPC\n GOODBYE!!!");
SifExitRpc();
ee_kmode_enter();
*(u32*)0x800002FC = HookValue;
ee_kmode_exit();
LoadExecPS2((const char *)bootFileName, 0, NULL);
SleepThread();
}
示例6: ioThreadDispatcher
// From PS2DEV.ORG - Thread dispatcher
static void ioThreadDispatcher ( void* apParam ) {
while ( ! gIOTerminate ) {
SleepThread ();
} /* end while */
ExitDeleteThread();
} /* end dispatcher */
示例7: rmEndFrame
void rmEndFrame(void) {
gsKit_set_finish(gsGlobal);
rmFlush();
// Wait for draw ops to finish
gsKit_finish();
if(!gsGlobal->FirstFrame)
{
SleepThread();
if(gsGlobal->DoubleBuffering == GS_SETTING_ON)
{
GS_SET_DISPFB2( gsGlobal->ScreenBuffer[gsGlobal->ActiveBuffer & 1] / 8192,
gsGlobal->Width / 64, gsGlobal->PSM, 0, 0 );
gsGlobal->ActiveBuffer ^= 1;
gsGlobal->PrimContext ^= 1;
}
}
gsKit_setactive(gsGlobal);
}
示例8: sleep_test
void sleep_test()
{
int i = 0;
int j = 0;
int sleep = 0;
while(1)
{
if (sleep == 1)
{
printf("WAKING UP\n");
sleep = 0;
}
if (i % 100000000 == 0)
{
int id = GetMyId();
printf("sleep_thread tid: %d j = %d\n", id, j);
j++;
}
if (j == 5)
{
j++;
printf("SLEEP FOR 5 SECONDS (tid: %d)\n", GetMyId());
sleep = 1;
SleepThread(5);
}
i++;
}
}
示例9: TxThread
static void TxThread(void *arg)
{
int ThreadToWakeUp;
while(1)
{
SleepThread();
if(PacketReqs.count > 0)
{
while(PacketReqs.count > 0)
{
WaitSema(NetManIOSemaID);
while(SifCallRpc(&NETMAN_rpc_cd, NETMAN_IOP_RPC_FUNC_SEND_PACKETS, 0, &PacketReqs, sizeof(PacketReqs), &ReceiveBuffer, sizeof(ReceiveBuffer.result), &TxEndCallback, NULL) < 0){};
SignalSema(NetManIOSemaID);
}
}
else
{
if(NetmanTxWaitingThread >= 0)
{
DI();
ThreadToWakeUp=NetmanTxWaitingThread;
NetmanTxWaitingThread=-1;
EI();
WakeupThread(ThreadToWakeUp);
}
}
}
}
示例10: WaitEx
// Wait for a event until the cancel flag becomes true
bool WaitEx(EVENT *e, UINT timeout, volatile bool *cancel)
{
bool dummy_bool = false;
UINT64 start, giveup;
// Validate arguments
if (cancel == NULL)
{
cancel = &dummy_bool;
}
start = Tick64();
if (timeout == INFINITE || timeout == 0x7FFFFFFF)
{
giveup = 0;
}
else
{
giveup = start + (UINT64)timeout;
}
while (true)
{
UINT64 now = Tick64();
UINT interval_to_giveup = (UINT)(giveup - now);
if (giveup == 0)
{
interval_to_giveup = INFINITE;
}
else
{
if (now >= giveup)
{
// Time-out occurs
return false;
}
}
interval_to_giveup = MIN(interval_to_giveup, 25);
if (*cancel)
{
// Cancel flag is set to true. Time-out occurs
return false;
}
if (e != NULL)
{
if (Wait(e, interval_to_giveup))
{
// Event is set
return true;
}
}
else
{
SleepThread(interval_to_giveup);
}
}
}
示例11: NetManRpcNetIFSendPacket
int NetManRpcNetIFSendPacket(const void *packet, unsigned int length){
struct PacketTag *PacketTag;
WaitSema(NetManTxSemaID);
NetmanTxWaitingThread=GetThreadId();
WaitSema(TxBankAccessSema);
//Check is there is space in the current Tx FIFO. If not, wait for the Tx thread to empty out the other FIFO. */
while(CurrentTxFIFOData->PacketReqs.NumPackets>=NETMAN_RPC_BLOCK_SIZE){
SignalSema(TxBankAccessSema);
WakeupThread(TxThreadID);
SleepThread();
WaitSema(TxBankAccessSema);
}
memcpy(&CurrentTxFIFOData->FrameBuffer[CurrentTxFIFOData->PacketReqs.TotalLength], packet, length);
PacketTag=&CurrentTxFIFOData->PacketReqs.tags[CurrentTxFIFOData->PacketReqs.NumPackets];
PacketTag->offset=CurrentTxFIFOData->PacketReqs.TotalLength;
PacketTag->length=length;
CurrentTxFIFOData->PacketReqs.TotalLength+=(length+3)&~3;
CurrentTxFIFOData->PacketReqs.NumPackets++;
WakeupThread(TxThreadID);
SignalSema(TxBankAccessSema);
NetmanTxWaitingThread=-1;
SignalSema(NetManTxSemaID);
return 0;
}
示例12: 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);
}
示例13: WinMain
// WinMain function
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, char *CmdLine, int CmdShow)
{
INSTANCE *instance;
is_debug = false;
MayaquaMinimalMode();
InitMayaqua(false, is_debug, 0, NULL);
InitCedar();
ViSetSkip();
ViLoadStringTables();
InitWinUi(_U(IDS_TITLE+skip), _A(IDS_FONT+skip), ToInt(_A(IDS_FONT_SIZE+skip)));
instance = NewSingleInstance(VI_INSTANCE_NAME);
if (instance == NULL)
{
MsgBox(NULL, MB_ICONINFORMATION, _U(IDS_INSTANCE_EXISTS+skip));
}
else
{
ViMain();
FreeSingleInstance(instance);
if (sleep_before_exit)
{
SleepThread(60 * 1000);
}
}
FreeWinUi();
ViFreeStringTables();
FreeCedar();
FreeMayaqua();
return 0;
}
示例14: testcase5_g
void testcase5_g(void)
{
int i = 0;
while (1)
{
i++;
if (i % 10000000 == 0)
{
printf("%s: id=%d: Current value i = %d\n", __FUNCTION__, GetMyId(), i);
if (i == 10000000)
{
printf("%s: id=%d: Sleeping thread.\n", __FUNCTION__, GetMyId());
SleepThread(2000);
}
if (i == 90000000)
{
printf("%s: id=%d: Deleteing thread 0. Return value = %d\n", __FUNCTION__, GetMyId(), DeleteThread(0));
}
if (i == 150000000)
{
CleanUp();
}
}
}
}
示例15: SifCallRpc
///////////////////////////////////////////////////////////////////////[10]
int SifCallRpc(struct sifcmd_RPC_CLIENT_DATA *client, unsigned int fno, unsigned int mode, void *send, int ssize, void *receive, int rsize, void (*end_func)(void*), void *end_para){
RPC_PACKET_CALL *packet;
if ((packet=(RPC_PACKET_CALL *)rpc_get_packet(&rpc_common))==0)
return -1;
client->hdr.pkt_addr=(void*)packet;
client->func = end_func;
client->param = end_para;
client->hdr.rpc_id= packet->packet.packet.pid;
packet->packet.packet.paddr = packet;
packet->packet.client = client;
packet->packet.fno = fno;
packet->size = ssize;
packet->receive= receive;
packet->rsize = rsize;
packet->server = client->server;
if (mode & 1){
packet->rmode=(end_func!=0);
client->hdr.tid=-1;
if (SifSendCmd(0x8000000A, packet, 0x40, send, client->buff, ssize))
return 0;
return -2;
}else{
packet->rmode=1;
client->hdr.tid=GetThreadId();
if (SifSendCmd(0x8000000A, packet, 0x40, send, client->buff, ssize)==0)
return -2;
SleepThread();
return 0;
}
}