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


C++ ThreadLock函数代码示例

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


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

示例1: GetThreadWork

/*
=============
GetThreadWork

=============
*/
int	GetThreadWork (void)
{
	int	r;
	int	f;

	ThreadLock ();

	if (dispatch == workcount)
	{
		ThreadUnlock ();
		return -1;
	}

	f = 10*dispatch / workcount;
	if (f != oldf)
	{
		oldf = f;
		if (pacifier)
			_printf ("%i...", f);
	}

	r = dispatch;
	dispatch++;
	ThreadUnlock ();

	return r;
}
开发者ID:Cpasjuste,项目名称:quake3_pandora_gles,代码行数:33,代码来源:threads.c

示例2: xmalloc

Rlist *RlistAppendAlien(Rlist **start, void *item)
   /* Allocates new memory for objects - careful, could leak!  */
{
    Rlist *rp, *lp = *start;

    rp = xmalloc(sizeof(Rlist));

    if (*start == NULL)
    {
        *start = rp;
    }
    else
    {
        for (lp = *start; lp->next != NULL; lp = lp->next)
        {
        }

        lp->next = rp;
    }

    rp->item = item;
    rp->type = RVAL_TYPE_SCALAR;

    ThreadLock(cft_lock);

    rp->next = NULL;

    ThreadUnlock(cft_lock);
    return rp;
}
开发者ID:arcimboldo,项目名称:cfengine,代码行数:30,代码来源:rlist.c

示例3: GetThreadWork

// get a new work for thread
int	GetThreadWork ( void )
{
	int	r;
	int	f;

	ThreadLock();
	if (dispatch >= workcount)
	{
		ThreadUnlock();
		return -1;
	}
	if (pacifier == qtrue)
	{
		f = 10 * dispatch / workcount;
		while ( oldf < f)
		{
			oldf++;
			Sys_Printf ("%i...", oldf);
		}
	}
	r = dispatch;
	dispatch++;
	ThreadUnlock ();
	return r;
}
开发者ID:paulvortex,项目名称:BloodMap,代码行数:26,代码来源:threads.c

示例4: GetThreadWork

/*
   =============
   GetThreadWork

   =============
 */
int GetThreadWork( void ){
	int r;
	int f;

	ThreadLock();

	if ( dispatch == workcount ) {
		ThreadUnlock();
		return -1;
	}

	f = 10 * dispatch / workcount;
	if ( f != oldf ) {
		oldf = f;
		if ( pacifier ) {
			Sys_Printf( "%i...", f );
			fflush( stdout );   /* ydnar */
		}
	}

	r = dispatch;
	dispatch++;
	ThreadUnlock();

	return r;
}
开发者ID:TTimo,项目名称:GtkRadiant,代码行数:32,代码来源:threads.c

示例5: switch

Rlist *RlistAppend(Rlist **start, const void *item, RvalType type)
{
    Rlist *rp, *lp = *start;

    switch (type)
    {
    case RVAL_TYPE_SCALAR:
        return RlistAppendScalar(start, item);

    case RVAL_TYPE_FNCALL:
        break;

    case RVAL_TYPE_LIST:
        for (rp = (Rlist *) item; rp != NULL; rp = rp->next)
        {
            lp = RlistAppend(start, rp->item, rp->type);
        }

        return lp;

    default:
        Log(LOG_LEVEL_DEBUG, "Cannot append %c to rval-list '%s'", type, (char *) item);
        return NULL;
    }

    rp = xmalloc(sizeof(Rlist));

    if (*start == NULL)
    {
        *start = rp;
    }
    else
    {
        for (lp = *start; lp->next != NULL; lp = lp->next)
        {
        }

        lp->next = rp;
    }

    rp->item = RvalCopy((Rval) {(void *) item, type}).item;
    rp->type = type;            /* scalar, builtin function */

    ThreadLock(cft_lock);

    if (type == RVAL_TYPE_LIST)
    {
        rp->state_ptr = rp->item;
    }
    else
    {
        rp->state_ptr = NULL;
    }

    rp->next = NULL;

    ThreadUnlock(cft_lock);

    return rp;
}
开发者ID:arcimboldo,项目名称:cfengine,代码行数:60,代码来源:rlist.c

示例6: LeafThread

/*
  ==============
  LeafThread
  ==============
*/
void *
LeafThread(void *arg)
{
    double now;
    portal_t *p;

    do {
        ThreadLock();
        /* Save state if sufficient time has elapsed */
        now = I_FloatTime();
        if (now > statetime + stateinterval) {
            statetime = now;
            SaveVisState();
        }
        ThreadUnlock();

        p = GetNextPortal();
        if (!p)
            break;

        PortalFlow(p);

        PortalCompleted(p);

        if (verbose > 1) {
            logprint("portal:%4i  mightsee:%4i  cansee:%4i\n",
                     (int)(p - portals), p->nummightsee, p->numcansee);
        }
    } while (1);

    return NULL;
}
开发者ID:kduske,项目名称:tyrutils-ericw,代码行数:37,代码来源:vis.c

示例7: DumpLuxels

// debugging! -- not accurate!
void DumpLuxels( facelight_t *pFaceLight, Vector *luxelColors, int ndxFace )
{
	static FileHandle_t pFpLuxels = NULL;

	ThreadLock();

	if( !pFpLuxels )
	{
		pFpLuxels = g_pFileSystem->Open( "luxels.txt", "w" );
	}

	dface_t *pFace = &g_pFaces[ndxFace];
	bool bDisp = ( pFace->dispinfo != -1 );

	for( int ndx = 0; ndx < pFaceLight->numluxels; ndx++ )
	{
		WriteWinding( pFpLuxels, pFaceLight->sample[ndx].w, luxelColors[ndx] );
		if( bDumpNormals && bDisp )
		{
			WriteNormal( pFpLuxels, pFaceLight->luxel[ndx], pFaceLight->luxelNormals[ndx], 15.0f, Vector( 255, 255, 0 ) );
		}
	}

	ThreadUnlock();
}
开发者ID:Baer42,项目名称:source-sdk-2013,代码行数:26,代码来源:radial.cpp

示例8: GetNextPortal

/*
  =============
  GetNextPortal

  Returns the next portal for a thread to work on
  Returns the portals from the least complex, so the later ones can reuse
  the earlier information.
  =============
*/
portal_t *
GetNextPortal(void)
{
    int i;
    portal_t *p, *ret;
    unsigned min;

    ThreadLock();

    min = INT_MAX;
    ret = NULL;

    for (i = 0, p = portals; i < numportals * 2; i++, p++) {
        if (p->nummightsee < min && p->status == pstat_none) {
            min = p->nummightsee;
            ret = p;
        }
    }

    if (ret) {
        ret->status = pstat_working;
        GetThreadWork_Locked__();
    }

    ThreadUnlock();

    return ret;
}
开发者ID:kduske,项目名称:tyrutils-ericw,代码行数:37,代码来源:vis.c

示例9: ThreadLock

/*
=============
AllocWinding
=============
*/
winding_t *AllocWinding (int points)
{
	winding_t	*w;

	if (numthreads == 1)
	{
		c_winding_allocs++;
		c_winding_points += points;
		c_active_windings++;
		if (c_active_windings > c_peak_windings)
			c_peak_windings = c_active_windings;
	}
	ThreadLock();
	if (winding_pool[points])
	{
		w = winding_pool[points];
		winding_pool[points] = w->next;
	}
	else
	{
		w = (winding_t *)malloc(sizeof(*w));
		w->p = (Vector *)calloc( points, sizeof(Vector) );
	}
	ThreadUnlock();
	w->numpoints = 0; // None are occupied yet even though allocated.
	w->maxpoints = points;
	w->next = NULL;
	return w;
}
开发者ID:Baer42,项目名称:source-sdk-2013,代码行数:34,代码来源:polylib.cpp

示例10: PurgeOldConnections

static void PurgeOldConnections(Item **list, time_t now)
   /* Some connections might not terminate properly. These should be cleaned
      every couple of hours. That should be enough to prevent spamming. */
{
    assert(list != NULL);

    Log(LOG_LEVEL_DEBUG, "Purging Old Connections...");

    if (ThreadLock(cft_count))
    {
        Item *ip, *next;
        for (ip = *list; ip != NULL; ip = next)
        {
            int then = 0;
            sscanf(ip->classes, "%d", &then);

            next = ip->next;

            if (now > then + 7200)
            {
                Log(LOG_LEVEL_VERBOSE,
                    "IP address '%s' has been more than two hours in connection list, purging",
                    ip->name);
                DeleteItem(list, ip);
            }
        }
        ThreadUnlock(cft_count);
    }

    Log(LOG_LEVEL_DEBUG, "Done purging old connections");
}
开发者ID:lra,项目名称:core,代码行数:31,代码来源:server.c

示例11: DlgDirListComboBoxW

int DlgDirListComboBoxW(
    HWND hwndDlg,
    LPWSTR lpszPathSpecClient,
    int idComboBox,
    int idStaticPath,
    UINT attrib)
{
    LPWSTR lpszPathSpec;
    PWND pwndDlg;
    TL tlpwndDlg;
    BOOL fRet;

    pwndDlg = ValidateHwnd(hwndDlg);

    if (pwndDlg == NULL)
        return FALSE;

    lpszPathSpec = lpszPathSpecClient;

    ThreadLock(pwndDlg, &tlpwndDlg);
    fRet = xxxDlgDirListHelper(pwndDlg, lpszPathSpec, (LPBYTE)lpszPathSpecClient,
            idComboBox, idStaticPath, attrib, FALSE);
    ThreadUnlock(&tlpwndDlg);

    return fRet;
}
开发者ID:Gaikokujin,项目名称:WinNT4,代码行数:26,代码来源:combodir.c

示例12: xxxAddFullScreen

BOOL xxxAddFullScreen(PWND pwnd)
{
    BOOL    fYielded;
    PDESKTOP pdesk = pwnd->head.rpdesk;

    CheckLock(pwnd);

    fYielded = FALSE;

    if (pdesk == NULL) return fYielded;

    if (!TestWF(pwnd, WFFULLSCREEN) && FCallTray(pdesk))
    {
        SetWF(pwnd, WFFULLSCREEN);

        if (!(pdesk->cFullScreen)++) {
            xxxSetTrayWindow(pdesk, STW_SAME);
            fYielded = TRUE;
        }

        if ((pwnd = pwnd->spwndOwner) && !TestWF(pwnd, WFCHILD) &&
                !pwnd->rcWindow.right && !pwnd->rcWindow.left && !TestWF(pwnd, WFVISIBLE)) {
            TL tlpwnd;
            ThreadLock(pwnd, &tlpwnd);
            if (xxxAddFullScreen(pwnd))
                fYielded = TRUE;
            ThreadUnlock(&tlpwnd);
        }
    }
    return(fYielded);
}
开发者ID:Gaikokujin,项目名称:WinNT4,代码行数:31,代码来源:winloop2.c

示例13: CompareResult

static int CompareResult(char *filename, char *prev_file)
{
    int i;
    unsigned char digest1[EVP_MAX_MD_SIZE + 1];
    unsigned char digest2[EVP_MAX_MD_SIZE + 1];
    int md_len1, md_len2;
    FILE *fp;
    int rtn = 0;

    CfOut(cf_verbose, "", "Comparing files  %s with %s\n", prev_file, filename);

    if ((fp = fopen(prev_file, "r")) != NULL)
    {
        fclose(fp);

        md_len1 = FileChecksum(prev_file, digest1);
        md_len2 = FileChecksum(filename, digest2);

        if (md_len1 != md_len2)
        {
            rtn = 1;
        }
        else
        {
            for (i = 0; i < md_len1; i++)
            {
                if (digest1[i] != digest2[i])
                {
                    rtn = 1;
                    break;
                }
            }
        }
    }
    else
    {
        /* no previous file */
        rtn = 1;
    }

    if (!ThreadLock(cft_count))
    {
        CfOut(cf_error, "", "!! Severe lock error when mailing in exec");
        return 1;
    }

/* replace old file with new*/

    unlink(prev_file);

    if (!LinkOrCopy(filename, prev_file, true))
    {
        CfOut(cf_inform, "", "Could not symlink or copy %s to %s", filename, prev_file);
        rtn = 1;
    }

    ThreadUnlock(cft_count);
    return (rtn);
}
开发者ID:FraserMCampbell,项目名称:core,代码行数:59,代码来源:cf-execd-runner.c

示例14: IncreaseNodeCounter

void IncreaseNodeCounter(void)
{
	ThreadLock();
	//if (verbose) printf("\r%6d", numrecurse++);
	qprintf("\r%6d", numrecurse++);
	//qprintf("\r%6d %d, %5d ", numrecurse++, GetNumThreads(), nodelistsize);
	ThreadUnlock();
} //end of the function IncreaseNodeCounter
开发者ID:Garux,项目名称:netradiant-custom,代码行数:8,代码来源:brushbsp.c

示例15: logvprint

void
logvprint(const char *fmt, va_list args)
{
    ThreadLock();
    InterruptThreadProgress__();
    logvprint_locked__(fmt, args);
    ThreadUnlock();
}
开发者ID:JoshEngebretson,项目名称:FSRadQuakeStuff,代码行数:8,代码来源:log.c


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