void AudioNode::ref(RefType refType) { switch (refType) { case RefTypeNormal: atomicIncrement(&m_normalRefCount); break; case RefTypeConnection: atomicIncrement(&m_connectionRefCount); break; case RefTypeDisabled: atomicIncrement(&m_disabledRefCount); break; default: ASSERT_NOT_REACHED(); } #if DEBUG_AUDIONODE_REFERENCES printf("%p: %d: AudioNode::ref(%d) %d %d %d\n", this, type(), refType, m_normalRefCount, m_connectionRefCount, m_disabledRefCount); #endif // See the disabling code in finishDeref() below. This handles the case where a node // is being re-connected after being used at least once and disconnected. // In this case, we need to re-enable. if (m_isDisabled && m_connectionRefCount > 0 && refType == RefTypeConnection) { ASSERT(isMainThread()); AudioContext::AutoLocker locker(context()); m_isDisabled = false; for (unsigned i = 0; i < m_outputs.size(); ++i) output(i)->enable(); } }
void AudioNode::ref(RefType refType) { #if ENABLE(OILPAN) ASSERT(m_keepAlive); #endif switch (refType) { case RefTypeNormal: atomicIncrement(&m_normalRefCount); break; case RefTypeConnection: atomicIncrement(&m_connectionRefCount); break; default: ASSERT_NOT_REACHED(); } #if DEBUG_AUDIONODE_REFERENCES fprintf(stderr, "%p: %d: AudioNode::ref(%d) %d %d\n", this, nodeType(), refType, m_normalRefCount, m_connectionRefCount); #endif // See the disabling code in finishDeref() below. This handles the case where a node // is being re-connected after being used at least once and disconnected. // In this case, we need to re-enable. if (refType == RefTypeConnection) enableOutputsIfNecessary(); }
Database::Database(VM& vm) : m_databaseID(atomicIncrement(&databaseCounter)) , m_vm(vm) , m_shouldSaveAtExit(false) , m_nextRegisteredDatabase(0) { }
int64_t IDBDatabase::nextTransactionId() { // Only keep a 32-bit counter to allow ports to use the other 32 // bits of the id. AtomicallyInitializedStatic(int, currentTransactionId = 0); return atomicIncrement(¤tTransactionId); }
Database::Database(JSGlobalData& globalData) : m_databaseID(atomicIncrement(&databaseCounter)) , m_globalData(globalData) , m_shouldSaveAtExit(false) , m_nextRegisteredDatabase(0) { }
ConditionVariable1::ConditionVariable1() { TRACE_CALL(lib_com.cnd, ("ConditionVariable1{0x%x}::ConditionVariable1", _T_PTR(this))); event_ = CreateEvent(0, true, false, 0); atomicIncrement(num_); }
ConditionVariable::ConditionVariable() { TRACE_CALL(lib_com.cnd, ("ConditionVariable{0x%x}::ConditionVariable", _T_PTR(this))); pthread_cond_init(&cid_, 0); atomicIncrement(num_); }
/////////////////////////////////////////////////////////////////////// // Class : CDelayedObject // Method : CDelayedObject // Description : /// \brief Ctor // Return Value : - // Comments : CDelayedObject::CDelayedObject(CAttributes *a,CXform *x,const float *bmin,const float *bmax,void (*subdivisionFunction)(void *,float),void (*freeFunction)(void *),void *data,int *drc) : CObject(a,x) { atomicIncrement(&stats.numDelayeds); movvv(this->bmin,bmin); movvv(this->bmax,bmax); this->subdivisionFunction = subdivisionFunction; this->freeFunction = freeFunction; this->data = data; processed = FALSE; // Save the object space bounding box movvv(objectBmin,bmin); movvv(objectBmax,bmax); if (drc == NULL) { dataRefCount = new int; dataRefCount[0] = 0; } else { dataRefCount = drc; } dataRefCount[0]++; xform->transformBound(this->bmin,this->bmax); makeBound(this->bmin,this->bmax); }
int64_t IDBDatabase::nextTransactionId() { // Only keep a 32-bit counter to allow ports to use the other 32 // bits of the id. static int currentTransactionId = 0; return atomicIncrement(¤tTransactionId); }
ConditionVariable1::ConditionVariable1() { TRACE_CALL(lib_com.cnd, ("ConditionVariable1{0x%x}::ConditionVariable1", _T_PTR(this))); signalled_ = false; pthread_cond_init(&cid_, 0); atomicIncrement(num_); }
void RefCountedLeakCounter::increment() { #if ENABLE(JSC_MULTIPLE_THREADS) atomicIncrement(&m_count); #else ++m_count; #endif }
uint64_t StatisticsRequest::addOutstandingRequest() { static int64_t uniqueRequestID; uint64_t requestID = atomicIncrement(&uniqueRequestID); m_outstandingRequests.add(requestID); return requestID; }
void ReadWriteLock::lockReader() { mImpl->mutex.lock(); atomicIncrement(&mImpl->readerCounter); mImpl->mutex.unlock(); }
/////////////////////////////////////////////////////////////////////// // Class : CXform // Method : CXform // Description : Constructor // Return Value : - // Comments : Identity at the beginning CXform::CXform() { atomicIncrement(&stats.numXforms); next = NULL; identitym(from); identitym(to); flip = 0; }
void Database::addDatabaseToAtExit() { if (atomicIncrement(&didRegisterAtExit) == 1) atexit(atExitCallback); TCMalloc_SpinLockHolder holder(®istrationLock); m_nextRegisteredDatabase = firstDatabase; firstDatabase = this; }
void doPark(ThreadState* state, intptr_t* stackEnd) { state->recordStackEnd(stackEnd); MutexLocker locker(m_mutex); if (!atomicDecrement(&m_unparkedThreadCount)) m_parked.signal(); while (!acquireLoad(&m_canResume)) m_resume.wait(m_mutex); atomicIncrement(&m_unparkedThreadCount); }
GPBase& GPBase::assign (GPEnabled *nptr) { if (nptr && atomicIncrement(&nptr->count) <= 0) nptr = 0; GPEnabled *optr = (GPEnabled*)atomicExchangePointer((void**)&ptr, (void*)nptr); if (optr) optr->unref(); return *this; }
/////////////////////////////////////////////////////////////////////// // Class : CXform // Method : CXform // Description : Create an exact copy of another xform // Return Value : - // Comments : CXform::CXform(CXform *a) { atomicIncrement(&stats.numXforms); if (a->next != NULL) next = new CXform(a->next); else next = NULL; movmm(from,a->from); movmm(to,a->to); flip = a->flip; }
void DNSResolveQueue::fired() { int requestsAllowed = maxRequestsToSend - m_requestsInFlight; for (HashSet<String>::iterator iter = m_names.begin(); iter != m_names.end() && requestsAllowed > 0; ++iter, --requestsAllowed) { atomicIncrement(&m_requestsInFlight); resolve(*iter); } // It's better to skip some names than to clog the queue. m_names.clear(); }
/////////////////////////////////////////////////////////////////////// // Class : CObject // Method : CObject // Description : /// \brief Ctor // Return Value : - // Comments : CObject::CObject(CAttributes *a,CXform *x) { atomicIncrement(&stats.numObjects); flags = 0; attributes = a; xform = x; attributes->attach(); xform->attach(); children = NULL; sibling = NULL; }
void DNSResolveQueue::fired() { int requestsAllowed = maxSimultaneousRequests - m_requestsInFlight; for (; !m_names.isEmpty() && requestsAllowed > 0; --requestsAllowed) { atomicIncrement(&m_requestsInFlight); HashSet<String>::iterator currentName = m_names.begin(); resolve(*currentName); m_names.remove(currentName); } if (!m_names.isEmpty()) startOneShot(retryResolvingInSeconds); }
/////////////////////////////////////////////////////////////////////// // Class : CDLObject // Method : CDLObject // Description : /// \brief Ctor // Return Value : - // Comments : CDLObject::CDLObject(CAttributes *a,CXform *x,void *handle,void *data,const float *bmi,const float *bma,dloInitFunction initFunction,dloIntersectFunction intersectFunction,dloTiniFunction tiniFunction) : CSurface(a,x) { atomicIncrement(&stats.numGprims); this->handle = handle; this->initFunction = initFunction; this->intersectFunction = intersectFunction; this->tiniFunction = tiniFunction; this->data = data; movvv(this->bmin,bmi); movvv(this->bmax,bma); xform->transformBound(bmin,bmax); makeBound(bmin,bmax); }
static void parallel_do_impl(boost::function<void ()> dg, size_t &completed, size_t total, boost::exception_ptr &exception, Scheduler *scheduler, Fiber::ptr caller) { try { dg(); } catch (boost::exception &ex) { removeTopFrames(ex); exception = boost::current_exception(); } catch (...) { exception = boost::current_exception(); } if (atomicIncrement(completed) == total) scheduler->schedule(caller); }
/////////////////////////////////////////////////////////////////////// // Class : CDelayedInstance // Method : CDelayedInstance // Description : /// \brief Ctor // Return Value : - // Comments : CDelayedInstance::CDelayedInstance(CAttributes *a,CXform *x,CObject *in) : CObject(a,x) { atomicIncrement(&stats.numDelayeds); instance = in; processed = FALSE; initv(bmin,C_INFINITY); initv(bmax,-C_INFINITY); CObject *cObject; for (cObject=instance;cObject!=NULL;cObject=cObject->sibling) { addBox(bmin,bmax,cObject->bmin); addBox(bmin,bmax,cObject->bmax); } xform->transformBound(this->bmin,this->bmax); makeBound(this->bmin,this->bmax); }
/////////////////////////////////////////////////////////////////////// // Class : CAttributes // Method : CAttributes // Description : This functions creates an exact replica of // another attribute set // Return Value : - // Comments : CAttributes::CAttributes(const CAttributes *a) { CActiveLight *cLight,*nLight; atomicIncrement(&stats.numAttributes); this[0] = a[0]; // Note: The assignment here also invokes the assignment operator of userAttributes // so there's no need for a separate copy for that refCount = 0; if (surface != NULL) surface->attach(); if (displacement != NULL) displacement->attach(); if (atmosphere != NULL) atmosphere->attach(); if (interior != NULL) interior->attach(); if (exterior != NULL) exterior->attach(); if (globalMapName != NULL) globalMapName = strdup(a->globalMapName); if (causticMapName != NULL) causticMapName = strdup(a->causticMapName); if (globalMap != NULL) globalMap->attach(); if (causticMap != NULL) causticMap->attach(); irradianceHandle = (a->irradianceHandle == NULL ? NULL : strdup(a->irradianceHandle)); irradianceHandleMode = (a->irradianceHandleMode == NULL ? NULL : strdup(a->irradianceHandleMode)); if (a->maxDisplacementSpace != NULL) maxDisplacementSpace = strdup(a->maxDisplacementSpace); lightSources = NULL; for (cLight=a->lightSources;cLight!=NULL;cLight=cLight->next) { nLight = new CActiveLight; nLight->light = cLight->light; nLight->next = lightSources; lightSources = nLight; } name = (a->name != NULL ? strdup(a->name) : NULL); if (a->next != NULL) next = new CAttributes(a->next); }
bool ConditionVariable::wait(Mutex* mutex, int msec) { TRACE_CALL(lib_com.cnd, ("ConditionVariable{0x%x}::wait", _T_PTR(this))); HANDLE h = CreateEvent(0, true, false, 0); atomicIncrement(num_); events_.push_back(h); mutex->unlock(); bool res = (WAIT_TIMEOUT != WaitForSingleObject(h, msec ? msec : INFINITE)); mutex->lock(); for (std::vector<HANDLE>::iterator i = events_.begin(); i != events_.end(); i++) if (*i == h) { events_.erase(i); break; } CloseHandle(h); atomicDecrement(num_); return res; }
/////////////////////////////////////////////////////////////////////// // Class : CBSplinePatchGrid // Method : CBSplinePatchGrid // Description : /// \brief Ctor // Return Value : - // Comments : CBSplinePatchGrid::CBSplinePatchGrid(CAttributes *a,CXform *x,CVertexData *var,CParameter *p,int nu,int nv,float uOrg,float vOrg,float uMult,float vMult,float *ve) : CSurface(a,x) { atomicIncrement(&stats.numGprims); variables = var; variables->attach(); parameters = p; uVertices = nu; vVertices = nv; this->uOrg = uOrg; this->vOrg = vOrg; this->uMult = uMult; this->vMult = vMult; const int numVertices = (nu*nv); int i,j,k; matrix ut; matrix bsplinebasis; matrix geometryU,geometryV; matrix tmp; const int upatches = uVertices - 3; const int vpatches = vVertices - 3; initv(bmin,C_INFINITY,C_INFINITY,C_INFINITY); initv(bmax,-C_INFINITY,-C_INFINITY,-C_INFINITY); // Note that u basis and v basis are swapped to take the transpose into account done during the precomputation // Note also that we could use the B-spline basis to bound the curve, but Bezier bound is tighter for (i=0;i<4;i++) for (j=0;j<4;j++) bsplinebasis[element(i,j)] = RiBSplineBasis[j][i]; transposem(ut,bsplinebasis); mulmm(geometryV,invBezier,ut); mulmm(geometryU,bsplinebasis,invBezier); // alloc off upatches*vpatches*16*vertexSize worth of data const int vertexSize = var->vertexSize; const int vs = (variables->moving ? vertexSize*2 : vertexSize); vertex = new float[vs*16*upatches*vpatches]; for (i=0;i<vpatches;i++) { for (j=0;j<upatches;j++) { int r,c; float *patchData = vertex + (i*upatches + j)*16*vertexSize; // Fill in the geometry matrices for (r=0;r<4;r++) { int y = (r + i) % vVertices; for (c=0;c<4;c++) { int x = (c + j) % uVertices; const float *d = ve + (y*uVertices+x)*vs; for (k=0;k<vertexSize;k++) { patchData[16*k + element(r,c)] = *d++; } } } // add to bounds makeCubicBound(bmin,bmax,patchData+0*16,patchData+1*16,patchData+2*16); // precompute B*G*B' and stash it for (k=0;k<vertexSize;k++) { mulmm(tmp,ut,patchData); mulmm(patchData,tmp,bsplinebasis); patchData += 16; } // do the same for moving points if (variables->moving) { patchData = vertex + (upatches*vpatches + i*upatches + j)*16*vertexSize; for (r=0;r<4;r++) { int y = (r + i) % vVertices; for (c=0;c<4;c++) { int x = (c + j) % uVertices; const float *d = ve + vertexSize + (y*uVertices+x)*vs; for (k=0;k<vertexSize;k++) { patchData[16*k + element(r,c)] = *d++; } } } // add to bounds makeCubicBound(bmin,bmax,patchData+0*16,patchData+1*16,patchData+2*16); // precompute B*G*B' and stash it for (k=0;k<vertexSize;k++) { mulmm(tmp,ut,patchData); mulmm(patchData,tmp,bsplinebasis); patchData += 16; } } } } makeBound(bmin,bmax); }
String16 V8ProfilerAgentImpl::nextProfileId() { return String16::fromInteger(atomicIncrement(&s_lastProfileId)); }
void AudioContext::incrementActiveSourceCount() { atomicIncrement(&m_activeSourceCount); }
explicit ScopedAtomicIncrementer(atomic_t& count_) : count(count_), decremented(false) { atomicIncrement(count); }