本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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");
}
示例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;
}
示例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);
}
示例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);
}
示例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
示例15: logvprint
void
logvprint(const char *fmt, va_list args)
{
ThreadLock();
InterruptThreadProgress__();
logvprint_locked__(fmt, args);
ThreadUnlock();
}