本文整理汇总了C++中CriticalSection::enter方法的典型用法代码示例。如果您正苦于以下问题:C++ CriticalSection::enter方法的具体用法?C++ CriticalSection::enter怎么用?C++ CriticalSection::enter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CriticalSection
的用法示例。
在下文中一共展示了CriticalSection::enter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JUCETaskCreate
void JUCETaskCreate(void (*pvTaskCode)(void * ), const signed char *pcName,
void *pvParameters, int uxPriority, int *pxCreatedTask)
{
tasklistmutex.enter();
if (arrayinited != true)
{
for (unsigned int i = 0; i < MAX_JUCETASKS; i++)
{
taskArray[i] = NULL;
}
arrayinited = true;
}
unsigned int thisID = MAX_JUCETASKS;
for (unsigned int i = 0; i < MAX_JUCETASKS; i++)
{
if (taskArray[i] == NULL)
{
thisID = i;
break;
}
}
if (thisID == MAX_JUCETASKS) return;
JUCETask *newtask;
String newname = (const char*) pcName;
newtask = new JUCETask(newname);
newtask->TaskFunction = pvTaskCode;
newtask->parameters = pvParameters;
newtask->iD = thisID;
taskArray[thisID] = newtask;
if (pxCreatedTask != NULL) *pxCreatedTask = thisID;
newtask->startThread(uxPriority);
tasklistmutex.exit();
}
示例2: registerService
int ServiceManager::registerService(waServiceFactory *service, GUID owner) {
ASSERT(owner != INVALID_GUID);
if (owner == INVALID_GUID) return 0;
GUID svctype = GetServiceTypeL(service);
cs.enter();
if (!services.multiHaveItem(svctype, service)) {
services.multiAddItem(svctype, service);
ownermap.addItem(service, owner);
GUID svcguid = service->getGuid();
if (svcguid != INVALID_GUID) services_by_guid.addItem(svcguid, service);
}
cs.leave();
service->serviceNotify(SvcNotify::ONREGISTERED);
#ifdef WASABI_COMPILE_SYSCB
CallbackManager::issueCallback(SysCallback::SERVICE,
SvcCallback::ONREGISTER,
reinterpret_cast<long>(&svctype), reinterpret_cast<long>(service));
#endif
return 1;
}
示例3: MutexList_Del
void MutexList_Del(CriticalSection *mutexPointer)
{
queuelistmutex.enter();
if (mutexPointer != NULL &&
MutexList != NULL)
{
MutexList_t *temp = MutexList;
MutexList_t *prev = NULL;
while (temp != NULL)
{
if (temp->mutexPointer == mutexPointer)
{
break;
}
prev = temp;
temp = temp->next;
}
if (prev == NULL)
{
MutexList = temp->next;
} else {
prev->next = temp->next;
}
delete temp;
queuelistmutex.exit();
}
}
示例4: empty
bool empty()
{
c_region.enter();
bool res = (active_buffers == 0);
c_region.leave();
return res;
}
示例5: sendNotification
void ServiceManager::sendNotification(int msg, int param1, int param2) {
cs.enter();
for (int x = 0; x < services.multiGetNumPairs(); x++) {
for (int y = 0; ; y++) {
waServiceFactory *svc;
if (!services.multiGetItemDirect(x, y, &svc)) {
break;
}
svc->serviceNotify(msg, param1, param2);
}
}
cs.leave();
#ifdef WASABI_COMPILE_COMPONENTS
// also notify components
for (int i = 0; ; i++) {
WaComponent *wac = ComponentManager::enumComponent(i);
if (wac == NULL) break;
wac->onNotify(WAC_NOTIFY_SERVICE_NOTIFY, msg, param1, param2);
}
#endif
#ifdef WASABI_COMPILE_SYSCB
// and syscallbacks
CallbackManager::issueCallback(SysCallback::RUNLEVEL, msg);
#endif
}
示例6: lock
void lock()
{
#ifdef DEBUG
if (locked) throw "Already locked";
#endif
cs->enter();
locked = true;
}
示例7: JUCETaskResume
void JUCETaskResume(int taskID)
{
tasklistmutex.enter();
JUCETask *thistask;
thistask = taskArray[taskID];
tasklistmutex.exit();
if (thistask != NULL) thistask->startThread();
}
示例8: pop
void pop (_et &element)
{
data_avail.wait();
c_region.enter();
element = elements[first];
first = (first + 1) % element_count;
active_buffers--;
c_region.leave();
free_space.signal();
}
示例9: push
void push(const _et &element)
{
free_space.wait();
c_region.enter();
int next = (last + 1) % element_count;
elements[last] = element;
last = next;
active_buffers++;
c_region.leave();
data_avail.signal();
}
示例10: MutexList_Add
void MutexList_Add(CriticalSection *mutexPointer, int mutexID)
{
queuelistmutex.enter();
MutexList_t *root = MutexList;
MutexList_t *newentry = new MutexList_t;
newentry->mutexID = mutexID;
newentry->mutexPointer = mutexPointer;
newentry->next = root;
MutexList = newentry;
queuelistmutex.exit();
}
示例11: lock
bool lock(SessionId owner,bool exclusive, unsigned timeout)
{
CTimeMon tm(timeout);
sect.enter();
loop {
unsigned num = owners.ordinality();
if (exclusive) {
if (num==0) {
owners.append(owner);
exclusivenest = 1;
break;
}
else if (exclusivenest && (owners.item(0)==owner)) {
exclusivenest++;
break;
}
}
else if (!exclusivenest) {
owners.append(owner);
break;
}
waiting++;
sect.leave();
unsigned remaining;
if (tm.timedout(&remaining)||!sem.wait(remaining)) {
sect.enter();
if (!sem.wait(0)) {
waiting--;
sect.leave();
return false;
}
}
else
sect.enter();
}
sect.leave();
return true;
}
示例12: release
int ServiceManager::release(void *svcptr) {
if (svcptr == NULL) return 0;
waServiceFactory *wsvc = NULL;
cs.enter(); // note cs getting locked twice via release+unlock
if (!lockmap.getItem(svcptr, &wsvc)) {
cs.leave();
DebugString("WARNING: got release with no lock record!");
return 0;
}
unlock(svcptr);
cs.leave();
ASSERT(wsvc != NULL);
return wsvc->releaseInterface(svcptr);
}
示例13: JUCETaskSuspend
void JUCETaskSuspend(int taskID)
{
tasklistmutex.enter();
JUCETask *thistask;
thistask = taskArray[taskID];
tasklistmutex.exit();
if (thistask != NULL)
{
if (Thread::getCurrentThreadId() != thistask->getThreadId())
{
thistask->stopThread(5000);
}
else thistask->signalThreadShouldExit();
}
}
示例14: MutexListList_GetID
int MutexListList_GetID(CriticalSection *mutexPointer)
{
queuelistmutex.enter();
MutexList_t *temp = MutexList;
int returnID = -1;
while (temp != NULL)
{
if (temp->mutexPointer == mutexPointer)
{
returnID = temp->mutexID;
break;
}
temp = temp->next;
}
queuelistmutex.exit();
return returnID;
}
示例15: JUCETaskResumeAll
void JUCETaskResumeAll(void)
{
tasklistmutex.enter();
JUCETask *thistaskArray[MAX_JUCETASKS];
for (unsigned int i = 0; i < MAX_JUCETASKS; i++)
{
thistaskArray[i] = taskArray[i];
}
tasklistmutex.exit();
for (unsigned int i = 0; i < MAX_JUCETASKS; i++)
{
if (thistaskArray[i] != NULL)
{
thistaskArray[i]->startThread();
}
}
}