本文整理汇总了C++中ThreadCreate函数的典型用法代码示例。如果您正苦于以下问题:C++ ThreadCreate函数的具体用法?C++ ThreadCreate怎么用?C++ ThreadCreate使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ThreadCreate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
int i;
/* Initialization Part */
DosInit();
TcbInitAll();
/*TODO*/
BufInitAll();
/* Get access to the entry address of clock intrrupt */
old_int8 = getvect(8);
clrscr();
tcbs[0].state = RUNNING;
current = 0; /* current thread */
ThreadCreate(sndThdName,(codeptr)Sender,STACK_SIZE);
ThreadCreate(recvThdName,(codeptr)Receiver,STACK_SIZE);
setvect(8, new_int8);
my_swtch();
TcbState();
while(!ThreadFinished());
TcbState();
setvect(8, old_int8); /* Recover old clock interrupt */
ThreadDestory(0);
return 0;
}
示例2: main
int main()
{
ThreadCreate(print2, '1');
ThreadCreate(print2, '2');
ThreadCreate(print2, '3');
print3('a');
ThreadCreate(print2, '4');
ThreadCreate(print2, '5');
ThreadExit();
}
示例3: TestPcp
void TestPcp()
{
pthread_t writeId;
pthread_t readId1;
pthread_t readId2;
TestPcpInit( 16, 5, 704 * 576 * 3 / 2 );
ThreadCreate( &readId1, TestPcpRead1, NULL );
ThreadCreate( &readId2, TestPcpRead2, NULL );
sleep( 2 );
ThreadCreate( &writeId, TestPcpWriteThread, NULL );
}
示例4: main
int main()
{
SchedSet(NULL, NULL, SCHED_RR, NULL);
SyncTypeCreate(_NTO_SYNC_SEM, &Semaphore, NULL); // initial count: 0
ThreadCreate(NULL, Thread1, NULL, NULL);
ThreadCreate(NULL, Thread1, NULL, NULL);
sleep(3);
ThreadCreate(NULL, Thread2, NULL, NULL);
SchedYield();
sleep(11);
return(0);
}
示例5: ehMpd
int ehMpd(MW_EVENT event, int argi, void* argp)
{
switch (event) {
case MW_INIT:
if (mpConsoleMutex) return 0; // already inited
memset(&mpx,0,sizeof(mpx));
MutexCreate(&mpConsoleMutex);
if (loopclip) ThreadCreate(&mpThreadHandle, mpThread, 0);
break;
case MW_UNINIT:
MutexDestroy(&mpConsoleMutex);
mpClose();
break;
case MW_PARSE_ARGS: {
int i = 0;
char** argv = (char**)argp;
for (i = 0; i < argi; i++) {
if (!strcmp(argv[i], "--mploop")) {
loopclip = argv[++i];
break;
} else if (!strcmp(argv[i], "--mpbin")) {
mpbin = argv[++i];
}
}
} break;
}
return 0;
}
示例6: StopThread
void OperThreadWin::RunNewThread( const char* info, OperThreadFunc f, void* data )
{
StopThread();
clPtr<OperThreadParam> param = new OperThreadParam;
tNode = new OperThreadNode( this, info, data );
param->func = f;
param->node = tNode;
MutexLock lock( &operMutex );
try
{
int n = NewThreadID();
//printf("TN=%i\n", n);
param->IncRefCount();
ThreadCreate( n, __123___OperThread, param.ptr() );
threadId = n;
param.drop(); //!!!
}
catch ( ... )
{
delete tNode;
tNode = 0;
}
}
示例7: HPRegisterForHotplugEvents
/**
* Sets up callbacks for device hotplug events.
*/
ULONG HPRegisterForHotplugEvents(void)
{
struct udev *udev;
(void)pthread_mutex_init(&usbNotifierMutex, NULL);
if (driverSize <= 0)
{
Log1(PCSC_LOG_INFO, "No bundle files in pcsc drivers directory: "
PCSCLITE_HP_DROPDIR);
Log1(PCSC_LOG_INFO, "Disabling USB support for pcscd");
return 0;
}
/* Create the udev object */
udev = udev_new();
if (!udev)
{
Log1(PCSC_LOG_ERROR, "udev_new() failed");
return 0;
}
HPRescanUsbBus(udev);
(void)ThreadCreate(&usbNotifyThread, THREAD_ATTR_DETACHED,
(PCSCLITE_THREAD_FUNCTION( )) HPEstablishUSBNotifications, udev);
return 0;
} /* HPRegisterForHotplugEvents */
示例8: RECOVERABLE_ASSERT
bool Thread::Start(const std::string& name){
RECOVERABLE_ASSERT(m_handle == nullptr);
m_handle = ThreadCreate(name, ThreadClassEntry, this);
return (m_handle != nullptr);
}
示例9: main
int
main(int argc, char **argv)
{
InitTerminalDriver();
InitTerminal(1);
if (argc > 1) HardwareOutputSpeed(1, atoi(argv[1]));
if (argc > 2) HardwareInputSpeed(1, atoi(argv[2]));
ThreadCreate(writer1, NULL);
ThreadCreate(writer2, NULL);
ThreadWaitAll();
exit(0);
}
示例10: calendar_manager_thread_init
void calendar_manager_thread_init(void)
{
thread_hdl thread_id;
Bool ret = FAILURE;
ret = ThreadCreate( &thread_id,
THREAD_CALENDAR_MANAGER_NAME,
THREAD_DEFAULT_PRIORITY,
NULL,
THREAD_DEFAULT_STACK_SIZE,
calendar_manager_thread_entry,
(void *)(NULL) );
if(FAILURE == ret)
{
CALENDER_DEBUG("Failed to create thread.");
calendar_quit();
}
if(FAILURE == ThreadDetach(&thread_id))
{
CALENDER_DEBUG("Failed to detach thread.");
calendar_quit();
}
}
示例11: makeThread
static void
makeThread(TConn * const connectionP,
enum abyss_foreback const foregroundBackground,
abyss_bool const useSigchld,
const char ** const errorP) {
switch (foregroundBackground) {
case ABYSS_FOREGROUND:
connectionP->hasOwnThread = FALSE;
*errorP = NULL;
break;
case ABYSS_BACKGROUND: {
const char * error;
connectionP->hasOwnThread = TRUE;
ThreadCreate(&connectionP->threadP, connectionP,
&connJob, &threadDone, useSigchld,
&error);
if (error) {
xmlrpc_asprintf(errorP, "Unable to create thread to "
"process connection. %s", error);
xmlrpc_strfree(error);
} else
*errorP = NULL;
}
break;
} /* switch */
}
示例12: uhAsyncDataTest
int uhAsyncDataTest(UrlHandlerParam* param)
{
int ret = FLAG_DATA_STREAM | FLAG_TO_FREE;
HANDLER_DATA* hdata = (HANDLER_DATA*)param->hs->ptr;
if (param->pucBuffer) {
if (!hdata) {
// first invoke
hdata = param->hs->ptr = calloc(1, sizeof(HANDLER_DATA));
ThreadCreate(&hdata->thread, WriteContent, hdata);
param->dataBytes = 0;
} else {
if (hdata->state == 1) {
// done
ret = 0;
} else if (ThreadWait(hdata->thread, 10, 0)) {
// data not ready
param->dataBytes = 0;
} else {
// data ready
strcpy(param->pucBuffer, hdata->result);
param->dataBytes = strlen(param->pucBuffer);
hdata->state = 1;
}
}
} else {
// cleanup
ret = 0;
}
param->fileType=HTTPFILETYPE_TEXT;
return ret;
}
示例13: testThreads
static void testThreads()
{
/* be nice and start up the threads like they should be */
ThreadInit();
{
TThread *heapThread = (TThread *)malloc(sizeof(TThread));
int sleepTime = 3;
int numThreadsToSpawn = 5;
int i = 0;
for (i = 0; i<numThreadsToSpawn; ++i) {
assert(ThreadCreate(heapThread,
sillyThreadFn,
&sleepTime) == TRUE);
}
/* give the threads time to get fired up */
sleep(1);
assert(ThreadCount(THREAD_DEFAULT_CLASS) == numThreadsToSpawn);
/* give the threads time to run to completion */
sleep(sleepTime + 1);
assert(ThreadCount(THREAD_DEFAULT_CLASS) == 0);
}
}
示例14: HPRegisterForHotplugEvents
/*
* Sets up callbacks for device hotplug events.
*/
ULONG HPRegisterForHotplugEvents(void)
{
ThreadCreate(&sHotplugWatcherThread,
THREAD_ATTR_DEFAULT,
(PCSCLITE_THREAD_FUNCTION( )) HPDeviceNotificationThread, NULL);
return 0;
}
示例15: ThreadCreate
//---------------------------------------------------------------------------
void TSnapThread::Start()
{
if (!Started)
{
ThreadCreate();
Started = true;
}
}