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


C++ ThreadCreate函数代码示例

本文整理汇总了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;
}
开发者ID:mushroom-x,项目名称:OS-Assignment-2016,代码行数:35,代码来源:T4_R_S.c

示例2: main

int main()
{
  ThreadCreate(print2, '1');
  ThreadCreate(print2, '2');
  ThreadCreate(print2, '3');

  print3('a');

  ThreadCreate(print2, '4');
  ThreadCreate(print2, '5');

  ThreadExit();
}
开发者ID:michelmassamiri,项目名称:DeveloppedNachosOS,代码行数:13,代码来源:makethreads.c

示例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 );
}
开发者ID:lidongliangfly,项目名称:hi3515a-lsdvs,代码行数:14,代码来源:testPcp.cpp

示例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);
}
开发者ID:aditya7041,项目名称:My-Blog-Repository,代码行数:14,代码来源:Semaphore.c

示例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;
}
开发者ID:avih,项目名称:miniweb,代码行数:28,代码来源:mpd.c

示例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;
	}
}
开发者ID:0-wiz-0,项目名称:WCMCommander,代码行数:27,代码来源:operwin.cpp

示例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 */
开发者ID:kenieevan,项目名称:pcsc-lite,代码行数:32,代码来源:hotplug_libudev.c

示例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);
}
开发者ID:asocha,项目名称:Engine,代码行数:7,代码来源:Thread.cpp

示例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);
}
开发者ID:rf7,项目名称:comp421lab1,代码行数:16,代码来源:test4.c

示例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();
  }
}
开发者ID:Linhu86,项目名称:calendar,代码行数:25,代码来源:calendar_manager.c

示例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 */
}
开发者ID:austin98x,项目名称:opensips,代码行数:27,代码来源:abyss_conn.c

示例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;
}
开发者ID:wdxzzia,项目名称:MiniWeb,代码行数:32,代码来源:httphandler.c

示例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);
	}
}
开发者ID:cmjonze,项目名称:anacapa,代码行数:28,代码来源:t_thread.c

示例14: HPRegisterForHotplugEvents

/*
 * Sets up callbacks for device hotplug events.
 */
ULONG HPRegisterForHotplugEvents(void)
{
	ThreadCreate(&sHotplugWatcherThread,
		THREAD_ATTR_DEFAULT,
		(PCSCLITE_THREAD_FUNCTION( )) HPDeviceNotificationThread, NULL);

	return 0;
}
开发者ID:ZuyingWo,项目名称:PCSC,代码行数:11,代码来源:hotplug_macosx.c

示例15: ThreadCreate

//---------------------------------------------------------------------------
void TSnapThread::Start() 
{
    if (!Started)
    {
        ThreadCreate();
        Started = true;
    }
}
开发者ID:GermanBluefox,项目名称:ioBroker.s7,代码行数:9,代码来源:snap_threads.cpp


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