コード例 #1
0
ファイル: threads.c プロジェクト: strategist922/rsyslog
/* Start a new thread and add it to the list of currently
 * executing threads. It is added at the end of the list.
 * rgerhards, 2007-12-14
 */
rsRetVal thrdCreate(rsRetVal (*thrdMain)(thrdInfo_t*), rsRetVal(*afterRun)(thrdInfo_t *), sbool bNeedsCancel, uchar *name)
{
    DEFiRet;
    thrdInfo_t *pThis;

    assert(thrdMain != NULL);

    CHKiRet(thrdConstruct(&pThis));
    pThis->bIsActive = 1;
    pThis->pUsrThrdMain = thrdMain;
    pThis->pAfterRun = afterRun;
    pThis->bNeedsCancel = bNeedsCancel;
    pThis->name = ustrdup(name);
    pthread_create(&pThis->thrdID,
#ifdef HAVE_PTHREAD_SETSCHEDPARAM
                   &default_thread_attr,
#else
                   NULL,
#endif
                   thrdStarter, pThis);
    CHKiRet(llAppend(&llThrds, NULL, pThis));

finalize_it:
    RETiRet;
}
コード例 #2
0
ファイル: threads.c プロジェクト: newgene/rsyslogd-mongo
/* Start a new thread and add it to the list of currently
 * executing threads. It is added at the end of the list.
 * rgerhards, 2007-12-14
 */
rsRetVal thrdCreate(rsRetVal (*thrdMain)(thrdInfo_t*), rsRetVal(*afterRun)(thrdInfo_t *), sbool bNeedsCancel)
{
	DEFiRet;
	thrdInfo_t *pThis;
	int i;

	assert(thrdMain != NULL);

	CHKiRet(thrdConstruct(&pThis));
	pThis->bIsActive = 1;
	pThis->pUsrThrdMain = thrdMain;
	pThis->pAfterRun = afterRun;
	pThis->bNeedsCancel = bNeedsCancel;
	i = pthread_create(&pThis->thrdID, NULL, thrdStarter, pThis);
	CHKiRet(llAppend(&llThrds, NULL, pThis));

finalize_it:
	RETiRet;
}