QMUTEX_INLINEP FX::QMutex::QMutex ( FXuint  spinCount = 4000  ) 

Constructs a mutex with the given spin count.

Definition at line 502 of file int_QMutexImpl.h.

References FX::FXRollbackBase::dismiss(), FALSE, FXERRHM, FXERRHOS, FX::FXRBConstruct(), FX::FXRBNew(), FX::QMutexPrivate::lockCount, FX::FXProcess::noOfProcessors(), NULL, FX::QMutexPrivate::recurseCount, FX::FXAtomicInt::set(), FX::QMutexPrivate::spinCount, FX::QMutexImpl::systemProcessors, FX::QMutexPrivate::threadId, FX::QMutexImpl::waitObjectCache, FX::QMutexPrivate::wakeSema, FX::QMutexPrivate::wc, and FX::QMutexImpl::KernelWaitObjectCache::Entry::wo.

00502                                           : p(0)
00503 {
00504     FXRBOp unconstr=FXRBConstruct(this);
00505     FXERRHM(p=new QMutexPrivate);
00506 #ifndef FXDISABLE_THREADS
00507 #ifdef USE_OURMUTEX
00508     p->lockCount.set(-1);
00509     p->wakeSema.set(0);
00510     p->threadId=p->recurseCount=0;
00511     if(!QMutexImpl::systemProcessors)
00512         QMutexImpl::systemProcessors=FXProcess::noOfProcessors();
00513     p->spinCount=spinc; //(systemProcessors>1) ? spinc : 0;
00514 #ifdef USE_WINAPI
00515     if(!(p->wc=QMutexImpl::waitObjectCache.fetch()))
00516     {
00517         FXERRHM(p->wc=new QMutexImpl::KernelWaitObjectCache::Entry);
00518         FXRBOp unwc=FXRBNew(p->wc);
00519         FXERRHWIN(p->wc->wo=CreateEvent(NULL, FALSE, FALSE, NULL));
00520         unwc.dismiss();
00521     }
00522 #endif
00523 #ifdef USE_POSIX
00524 #ifdef MUTEX_USESEMA
00525     if(!(p->sema=QMutexImpl::waitObjectCache.fetch()))
00526     {
00527         FXERRHM(p->sema=new QMutexImpl::KernelWaitObjectCache::Entry);
00528         FXRBOp unsema=FXRBNew(p->sema);
00529         FXERRHOS(sem_init(&p->sema->wo, 0, 0));
00530         unsema.dismiss();
00531     }
00532 #else
00533     if(!(p->sema=QMutexImpl::waitObjectCache.fetch()))
00534     {
00535         FXERRHM(p->sema=new QMutexImpl::KernelWaitObjectCache::Entry);
00536         FXRBOp unsema=FXRBNew(p->sema);
00537         FXERRHOS(pthread_mutex_init(&p->sema->wo, NULL));
00538         unsema.dismiss();
00539     }
00540 #endif
00541 #endif
00542 #elif defined(USE_POSIX)
00543     pthread_mutexattr_t mattr;
00544     FXERRHOS(pthread_mutexattr_init(&mattr));
00545     FXERRHOS(pthread_mutexattr_setkind_np(&mattr, PTHREAD_MUTEX_RECURSIVE_NP));
00546     if(!(p->m=waitObjectCache.fetch()))
00547     {
00548         FXERRHM(p->m=new KernelWaitObjectCache::Entry);
00549         FXRBOp unm=FXRBNew(p->m);
00550         FXERRHOS(pthread_mutex_init(&p->m->wo, &mattr));
00551         unm.dismiss();
00552     }
00553     FXERRHOS(pthread_mutexattr_destroy(&mattr));
00554 #endif
00555 #endif
00556     unconstr.dismiss();
00557 }


(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:37:45 2009 for TnFOX by doxygen v1.4.7