本文整理匯總了C++中ENTERCRITICALSECTION函數的典型用法代碼示例。如果您正苦於以下問題:C++ ENTERCRITICALSECTION函數的具體用法?C++ ENTERCRITICALSECTION怎麽用?C++ ENTERCRITICALSECTION使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ENTERCRITICALSECTION函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: Association_initialize
objrtn Association_initialize(void)
{
static CRITICALSECTION cs;
static int volatile once = 0;
ENTERCRITICALSECTION(_CI_CS_);
if (!once) {
INITIALIZECRITICALSECTION(cs);
once = 1;
}
LEAVECRITICALSECTION(_CI_CS_);
ENTERCRITICALSECTION(cs);
if (Association_c) {
LEAVECRITICALSECTION(cs);
return Association_c;
}
INHIBIT_THREADER;
Association_c = gNewClass(Class, "Association", 0, 0, END);
ENABLE_THREADER;
LEAVECRITICALSECTION(cs);
return Association_c;
}
示例2: ArgumentList_initialize
objrtn ArgumentList_initialize(void)
{
static CRITICALSECTION cs;
static int volatile once = 0;
ENTERCRITICALSECTION(_CI_CS_);
if (!once) {
INITIALIZECRITICALSECTION(cs);
once = 1;
}
LEAVECRITICALSECTION(_CI_CS_);
ENTERCRITICALSECTION(cs);
if (ArgumentList_c) {
LEAVECRITICALSECTION(cs);
return ArgumentList_c;
}
INHIBIT_THREADER;
LinkObject_initialize();
if (ArgumentList_c) {
ENABLE_THREADER;
LEAVECRITICALSECTION(cs);
return ArgumentList_c;
}
ArgumentList_c = gNewClass(Class, "ArgumentList", 0, 0, LinkObject, END);
cMethodFor(ArgumentList, gNew, ArgumentList_cm_gNew);
cMethodFor(ArgumentList, gNewArglist, ArgumentList_cm_gNewArglist);
ENABLE_THREADER;
LEAVECRITICALSECTION(cs);
return ArgumentList_c;
}
示例3: InputStream_initialize
objrtn InputStream_initialize(void)
{
static CRITICALSECTION cs;
static int volatile once = 0;
ENTERCRITICALSECTION(_CI_CS_);
if (!once) {
INITIALIZECRITICALSECTION(cs);
once = 1;
}
LEAVECRITICALSECTION(_CI_CS_);
ENTERCRITICALSECTION(cs);
if (InputStream_c) {
LEAVECRITICALSECTION(cs);
return InputStream_c;
}
INHIBIT_THREADER;
InputStream_c = gNewClass(Class, "InputStream", sizeof(InputStream_iv_t), 0, END);
cMethodFor(InputStream, gNewWithStr, InputStream_cm_gNewWithStr);
cMethodFor(InputStream, gNew, InputStream_cm_gNew);
iMethodFor(InputStream, gDispose, InputStream_im_gDispose);
iMethodFor(InputStream, gGCDispose, InputStream_im_gGCDispose);
iMethodFor(InputStream, gLineHasColon, InputStream_im_gLineHasColon);
iMethodFor(InputStream, gNextToken, InputStream_im_gNextToken);
iMethodFor(InputStream, gDeepDispose, InputStream_im_gDispose);
ENABLE_THREADER;
LEAVECRITICALSECTION(cs);
return InputStream_c;
}
示例4: SeriousCondition_initialize
objrtn SeriousCondition_initialize(void)
{
static CRITICALSECTION cs;
static int volatile once = 0;
ENTERCRITICALSECTION(_CI_CS_);
if (!once) {
INITIALIZECRITICALSECTION(cs);
once = 1;
}
LEAVECRITICALSECTION(_CI_CS_);
ENTERCRITICALSECTION(cs);
if (SeriousCondition_c) {
LEAVECRITICALSECTION(cs);
return SeriousCondition_c;
}
INHIBIT_THREADER;
Condition_initialize();
if (SeriousCondition_c) {
ENABLE_THREADER;
LEAVECRITICALSECTION(cs);
return SeriousCondition_c;
}
SeriousCondition_c = gNewClass(Class, "SeriousCondition", 0, 0, Condition, END);
iMethodFor(SeriousCondition, gDefaultRestart, SeriousCondition_im_gDefaultRestart);
ENABLE_THREADER;
LEAVECRITICALSECTION(cs);
return SeriousCondition_c;
}
示例5: UnsignedShortInteger_initialize
objrtn UnsignedShortInteger_initialize(void)
{
static CRITICALSECTION cs;
static int volatile once = 0;
ENTERCRITICALSECTION(_CI_CS_);
if (!once) {
INITIALIZECRITICALSECTION(cs);
once = 1;
}
LEAVECRITICALSECTION(_CI_CS_);
ENTERCRITICALSECTION(cs);
if (UnsignedShortInteger_c) {
LEAVECRITICALSECTION(cs);
return UnsignedShortInteger_c;
}
INHIBIT_THREADER;
Number_initialize();
if (UnsignedShortInteger_c) {
ENABLE_THREADER;
LEAVECRITICALSECTION(cs);
return UnsignedShortInteger_c;
}
UnsignedShortInteger_c = gNewClass(Class, "UnsignedShortInteger", sizeof(UnsignedShortInteger_iv_t), 0, Number, END);
cMethodFor(UnsignedShortInteger, gNewWithUnsigned, UnsignedShortInteger_cm_gNewWithUnsigned);
iMethodFor(UnsignedShortInteger, gUnsignedShortValue, UnsignedShortInteger_im_gUnsignedShortValue);
iMethodFor(UnsignedShortInteger, gChangeDoubleValue, UnsignedShortInteger_im_gChangeDoubleValue);
iMethodFor(UnsignedShortInteger, gDoubleValue, UnsignedShortInteger_im_gDoubleValue);
iMethodFor(UnsignedShortInteger, gCompare, UnsignedShortInteger_im_gCompare);
iMethodFor(UnsignedShortInteger, gChangeLongValue, UnsignedShortInteger_im_gChangeLongValue);
iMethodFor(UnsignedShortInteger, gChangeShortValue, UnsignedShortInteger_im_gChangeShortValue);
iMethodFor(UnsignedShortInteger, gShortValue, UnsignedShortInteger_im_gShortValue);
iMethodFor(UnsignedShortInteger, gPointerValue, UnsignedShortInteger_im_gPointerValue);
iMethodFor(UnsignedShortInteger, gCharValue, UnsignedShortInteger_im_gCharValue);
iMethodFor(UnsignedShortInteger, gStringRepValue, UnsignedShortInteger_im_gStringRepValue);
iMethodFor(UnsignedShortInteger, gChangeUShortValue, UnsignedShortInteger_im_gChangeUShortValue);
iMethodFor(UnsignedShortInteger, gHash, UnsignedShortInteger_im_gHash);
iMethodFor(UnsignedShortInteger, gChangeValue, UnsignedShortInteger_im_gChangeValue);
iMethodFor(UnsignedShortInteger, gLongValue, UnsignedShortInteger_im_gLongValue);
iMethodFor(UnsignedShortInteger, gChangeCharValue, UnsignedShortInteger_im_gChangeCharValue);
ENABLE_THREADER;
LEAVECRITICALSECTION(cs);
return UnsignedShortInteger_c;
}
示例6: MA_compact
void MA_compact(void)
{
MemBlk *mb;
Header *fh, *mfh = NULL;
int i;
ENTERCRITICALSECTION(CS);
for (mb=MMBP ; mb ; mb = mb->next) {
fh = compact(mb);
if (fh) {
fh->next = mfh;
mfh = fh;
}
}
for (i=0 ; Map[i].userBytes ; ++i)
Map[i].h = NULL;
while (fh = mfh) {
mfh = fh->next;
fh->status = 'U';
fh->next = NULL;
MA_free(fh+1);
}
LEAVECRITICALSECTION(CS);
}
示例7: asASSERT
void asCThreadManager::Unprepare()
{
asASSERT(threadManager);
if( threadManager == 0 )
return;
// It's necessary to protect this section so no
// other thread attempts to call AddRef or Release
// while clean up is in progress.
ENTERCRITICALSECTION(threadManager->criticalSection);
if( --threadManager->refCount == 0 )
{
// Make sure the local data is destroyed, at least for the current thread
CleanupLocalData();
// As the critical section will be destroyed together
// with the thread manager we must first clear the global
// variable in case a new thread manager needs to be created;
asCThreadManager *mgr = threadManager;
threadManager = 0;
// Leave the critical section before it is destroyed
LEAVECRITICALSECTION(mgr->criticalSection);
asDELETE(mgr,asCThreadManager);
}
else
LEAVECRITICALSECTION(threadManager->criticalSection);
}
示例8: ENTERCRITICALSECTION
asCThreadLocalData *asCThreadManager::GetLocalData()
{
if( threadManager == 0 )
return 0;
#ifndef AS_NO_THREADS
#if defined AS_POSIX_THREADS
asPWORD id = (asPWORD)pthread_self();
#elif defined AS_WINDOWS_THREADS
asPWORD id = (asPWORD)GetCurrentThreadId();
#endif
ENTERCRITICALSECTION(threadManager->criticalSection);
asCThreadLocalData *tld = threadManager->GetLocalData(id);
if( tld == 0 )
{
// Create a new tld
tld = asNEW(asCThreadLocalData)();
if( tld )
threadManager->SetLocalData(id, tld);
}
LEAVECRITICALSECTION(threadManager->criticalSection);
return tld;
#else
if( threadManager->tld == 0 )
threadManager->tld = asNEW(asCThreadLocalData)();
return threadManager->tld;
#endif
}
示例9: ENTERCRITICALSECTION
int asCGarbageCollector::GetObjectInGC(asUINT idx, asUINT *seqNbr, void **obj, asIObjectType **type)
{
if( seqNbr ) *seqNbr = 0;
if( obj ) *obj = 0;
if( type ) *type = 0;
ENTERCRITICALSECTION(gcCritical);
asSObjTypePair *o = 0;
asUINT newObjs = gcNewObjects.GetLength();
if( idx < newObjs )
o = &gcNewObjects[idx];
else if( idx < gcOldObjects.GetLength() + newObjs )
o = &gcOldObjects[idx-newObjs];
else
{
LEAVECRITICALSECTION(gcCritical);
return asINVALID_ARG;
}
if( seqNbr ) *seqNbr = o->seqNbr;
if( obj ) *obj = o->obj;
if( type ) *type = o->type;
LEAVECRITICALSECTION(gcCritical);
return asSUCCESS;
}
示例10: ENTERCRITICALSECTION
void asCGarbageCollector::IncreaseCounterForNewObject(int idx)
{
// We need to protect this update with a critical section as
// another thread might be appending an object at the same time
ENTERCRITICALSECTION(gcCritical);
gcNewObjects[idx].count++;
LEAVECRITICALSECTION(gcCritical);
}
示例11: ENTERCRITICALSECTION
asDWORD asCAtomic::atomicDec()
{
asDWORD v;
ENTERCRITICALSECTION(cs);
v = --value;
LEAVECRITICALSECTION(cs);
return v;
}
示例12: IdentifyGarbageWithCyclicRefs
int asCGarbageCollector::AddScriptObjectToGC(void *obj, asCObjectType *objType)
{
if( obj == 0 || objType == 0 )
{
engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, TXT_GC_RECEIVED_NULL_PTR);
return asINVALID_ARG;
}
engine->CallObjectMethod(obj, objType->beh.addref);
asSObjTypePair ot = {obj, objType, 0};
// Invoke the garbage collector to destroy a little garbage as new comes in
// This will maintain the number of objects in the GC at a maintainable level without
// halting the application, and without burdening the application with manually invoking the
// garbage collector.
if( engine->ep.autoGarbageCollect && gcNewObjects.GetLength() )
{
// If the GC is already processing in another thread, then don't try this again
if( TRYENTERCRITICALSECTION(gcCollecting) )
{
// Skip this if the GC is already running in this thread
if( !isProcessing )
{
isProcessing = true;
// TODO: The number of iterations should be dynamic, and increase
// if the number of objects in the garbage collector grows high
// Run one step of DetectGarbage
if( gcOldObjects.GetLength() )
{
IdentifyGarbageWithCyclicRefs();
DestroyOldGarbage();
}
// Run a few steps of DestroyGarbage
int iter = (int)gcNewObjects.GetLength();
if( iter > 10 ) iter = 10;
while( iter-- > 0 )
DestroyNewGarbage();
isProcessing = false;
}
LEAVECRITICALSECTION(gcCollecting);
}
}
// Add the data to the gcObjects array in a critical section as
// another thread might be calling this method at the same time
ENTERCRITICALSECTION(gcCritical);
ot.seqNbr = numAdded++;
gcNewObjects.PushLast(ot);
LEAVECRITICALSECTION(gcCritical);
return ot.seqNbr;
}
示例13: ENTERCRITICALSECTION
void asCGarbageCollector::MoveAllObjectsToOldList()
{
// We need to protect this update with a critical section as
// another thread might be appending an object at the same time
ENTERCRITICALSECTION(gcCritical);
if( gcOldObjects.Concatenate(gcNewObjects) )
gcNewObjects.SetLength(0);
LEAVECRITICALSECTION(gcCritical);
}
示例14: BufferedTempFile_initialize
objrtn BufferedTempFile_initialize(void)
{
static CRITICALSECTION cs;
static int volatile once = 0;
ENTERCRITICALSECTION(_CI_CS_);
if (!once) {
INITIALIZECRITICALSECTION(cs);
once = 1;
}
LEAVECRITICALSECTION(_CI_CS_);
ENTERCRITICALSECTION(cs);
if (BufferedTempFile_c) {
LEAVECRITICALSECTION(cs);
return BufferedTempFile_c;
}
INHIBIT_THREADER;
BufferedTempFile_c = gNewClass(Class, "BufferedTempFile", sizeof(BufferedTempFile_iv_t), 0, END);
cMethodFor(BufferedTempFile, gOpenTempFile, BufferedTempFile_cm_gOpenTempFile);
iMethodFor(BufferedTempFile, gFlush, BufferedTempFile_im_gFlush);
iMethodFor(BufferedTempFile, gRetreat, BufferedTempFile_im_gRetreat);
iMethodFor(BufferedTempFile, gPosition, BufferedTempFile_im_gPosition);
iMethodFor(BufferedTempFile, gLength, BufferedTempFile_im_gLength);
iMethodFor(BufferedTempFile, gWrite, BufferedTempFile_im_gWrite);
iMethodFor(BufferedTempFile, gEndOfStream, BufferedTempFile_im_gEndOfStream);
iMethodFor(BufferedTempFile, gSeek, BufferedTempFile_im_gSeek);
iMethodFor(BufferedTempFile, gPointerValue, BufferedTempFile_im_gPointerValue);
iMethodFor(BufferedTempFile, gAdvance, BufferedTempFile_im_gAdvance);
iMethodFor(BufferedTempFile, gDispose, BufferedTempFile_im_gDispose);
iMethodFor(BufferedTempFile, gName, BufferedTempFile_im_gName);
iMethodFor(BufferedTempFile, gGets, BufferedTempFile_im_gGets);
iMethodFor(BufferedTempFile, gGCDispose, BufferedTempFile_im_gGCDispose);
iMethodFor(BufferedTempFile, gDeepDispose, BufferedTempFile_im_gDispose);
iMethodFor(BufferedTempFile, gRead, BufferedTempFile_im_gRead);
ENABLE_THREADER;
LEAVECRITICALSECTION(cs);
return BufferedTempFile_c;
}
示例15: ObjectPool_initialize
objrtn ObjectPool_initialize(void)
{
static CRITICALSECTION cs;
static int volatile once = 0;
ENTERCRITICALSECTION(_CI_CS_);
if (!once) {
INITIALIZECRITICALSECTION(cs);
once = 1;
}
LEAVECRITICALSECTION(_CI_CS_);
ENTERCRITICALSECTION(cs);
if (ObjectPool_c) {
LEAVECRITICALSECTION(cs);
return ObjectPool_c;
}
INHIBIT_THREADER;
ObjectPool_c = gNewClass(Class, "ObjectPool", sizeof(ObjectPool_iv_t), sizeof(ObjectPool_cv_t), END);
cMethodFor(ObjectPool, gNewGlobalPoolWithSize, ObjectPool_cm_gNewGlobalPoolWithSize);
cMethodFor(ObjectPool, gDisposeGlobalPool, ObjectPool_cm_gDisposeGlobalPool);
cMethodFor(ObjectPool, gRemoveFromPool, ObjectPool_cm_gRemoveFromPool);
cMethodFor(ObjectPool, gNewWithInt, ObjectPool_cm_gNewWithInt);
cMethodFor(ObjectPool, gAddToPool, ObjectPool_cm_gAddToPool);
cMethodFor(ObjectPool, gNew, ObjectPool_cm_gNew);
cMethodFor(ObjectPool, gNewGlobalPool, ObjectPool_cm_gNewGlobalPool);
cMethodFor(ObjectPool, gDisposeObject, ObjectPool_cm_gDisposeObject);
iMethodFor(ObjectPool, gRemoveFromPool, ObjectPool_im_gRemoveFromPool);
iMethodFor(ObjectPool, gAddToPool, ObjectPool_im_gAddToPool);
iMethodFor(ObjectPool, gDispose, ObjectPool_im_gDispose);
iMethodFor(ObjectPool, gDeepDispose, ObjectPool_im_gDispose);
iMethodFor(ObjectPool, gDisposeObject, ObjectPool_im_gDisposeObject);
ObjectPool_cv = GetCVs(ObjectPool);
ENABLE_THREADER;
LEAVECRITICALSECTION(cs);
return ObjectPool_c;
}