bool ring_fifo_is_empty(ring_fifo_t *cobj) { struct s_ring_fifo_private * obj = (struct s_ring_fifo_private *)cobj; PTR_CHECK_RETURN(obj, "ring_fifo", true); return _empty(obj); }
static bool _full(struct s_ring_fifo_private * obj) { if (_empty(obj)) return false; return ( ((obj->wr - obj->rd) >= obj->num_fifo_slots) ? true : false); }
void TCGenBinaryTree::_empty(TCBinaryTreeNode* t) /**************************************************************************** * * Function: TCGenBinaryTree::_empty * Parameters: t - Root of subtree to empty * * Description: Recursive routine to delete all the nodes in a specified * subtree. This routine is declared as static to reduce * the runtime stack overheads required. * ****************************************************************************/ { if (t != o_z) { _empty(t->left); _empty(t->right); delete t; } }
static BUFFER_PTR _rd_ptr(struct s_ring_fifo_private * obj) { uint32_t offset; if (_empty(obj)) return NULL; offset = (obj->rd % obj->num_fifo_slots) * obj->element_size; return obj->buffer + offset; }
static bool _discard_last_wr(struct s_ring_fifo_private * obj) { if (obj->nocp_push_started) return false; if (_empty(obj)) return false; obj->wr--; return true; }
BUFFER_PTR ring_fifo_zerocopy_pop_start(ring_fifo_t * cobj) { struct s_ring_fifo_private * obj = (struct s_ring_fifo_private *)cobj; PTR_CHECK_RETURN(obj, "ring_fifo", NULL); if (_empty(obj)) return NULL; obj->nocp_pop_started = true; return _rd_ptr(obj); }
INT32 _rtnContextMain::reopenForExplain ( INT64 numToSkip, INT64 numToReturn ) { INT32 rc = SDB_OK ; _empty() ; _resetTotalRecords( 0 ) ; _isOpened = TRUE ; _hitEnd = FALSE ; _numToSkip = numToSkip ; _numToReturn = numToReturn ; return rc ; }
bool ring_fifo_pop(ring_fifo_t *cobj, BUFFER_PTR to) { struct s_ring_fifo_private * obj = (struct s_ring_fifo_private *)cobj; PTR_CHECK_RETURN(obj, "ring_fifo", false); if (_empty(obj)) return false; if (to) memcpy(to, _rd_ptr(obj), obj->element_size); obj->rd++; return true; }
void TCGenBinaryTree::empty() /**************************************************************************** * * Function: TCGenBinaryTree::empty * * Description: Empties the tree of all nodes currently installed in the * tree. * ****************************************************************************/ { o_z = z; _empty(root->right); root->left = root->right = z->left = z->right = z; root->parent = z->parent = root; }
/* will delete those dofmanagers, that were sent to remote partition and are locally owned here * so they are no longer necessary (those with state equal to DM_Remote and DM_SharedMerge) * This will update domain DofManager list as well as global dmanMap and physically deletes the remote dofManager */ void LoadBalancer :: deleteRemoteDofManagers(Domain *d) { int i, ndofman = d->giveNumberOfDofManagers(); //LoadBalancer* lb = this->giveLoadBalancer(); LoadBalancer :: DofManMode dmode; DofManager *dman; int myrank = d->giveEngngModel()->giveRank(); DomainTransactionManager *dtm = d->giveTransactionManager(); // loop over local nodes for ( i = 1; i <= ndofman; i++ ) { dmode = this->giveDofManState(i); if ( ( dmode == LoadBalancer :: DM_Remote ) ) { // positive candidate found dtm->addTransaction(DomainTransactionManager :: DTT_Remove, DomainTransactionManager :: DCT_DofManager, d->giveDofManager(i)->giveGlobalNumber(), NULL); // dmanMap.erase (d->giveDofManager (i)->giveGlobalNumber()); //dman = dofManagerList->unlink (i); //delete dman; } else if ( ( dmode == LoadBalancer :: DM_NULL ) ) { // positive candidate found; we delete all null dof managers // they will be created by nonlocalmatwtp if necessary. // potentially, they can be reused, but this will make the code too complex dtm->addTransaction(DomainTransactionManager :: DTT_Remove, DomainTransactionManager :: DCT_DofManager, d->giveDofManager(i)->giveGlobalNumber(), NULL); } else if ( dmode == LoadBalancer :: DM_Shared ) { dman = d->giveDofManager(i); dman->setPartitionList( this->giveDofManPartitions(i) ); dman->setParallelMode(DofManager_shared); if ( !dman->givePartitionList()->findFirstIndexOf(myrank) ) { dtm->addTransaction(DomainTransactionManager :: DTT_Remove, DomainTransactionManager :: DCT_DofManager, d->giveDofManager(i)->giveGlobalNumber(), NULL); //dmanMap.erase (this->giveDofManager (i)->giveGlobalNumber()); //dman = dofManagerList->unlink (i); //delete dman; } } else if ( dmode == LoadBalancer :: DM_Local ) { IntArray _empty(0); dman = d->giveDofManager(i); dman->setPartitionList(& _empty); dman->setParallelMode(DofManager_local); } else { OOFEM_ERROR("Domain::deleteRemoteDofManagers: unknown dmode encountered"); } } }
unsigned int LuaRunBuffer::runBuffer() { if (!_script.isValid()) { VRJLUA_MSG_START(dbgVRJLUA_BUFFER, MSG_WARNING) << "in runBuffer, but init not run with a valid LuaScript " "state!" << VRJLUA_MSG_END(dbgVRJLUA_BUFFER, MSG_WARNING); return 0; } if (_empty()) { return 0; } unsigned int n = _buf.size(); unsigned int count(0); std::string current; VRJLUA_MSG_START(dbgVRJLUA_BUFFER, MSG_STATUS) << "In runBuffer, have " << n << " to run..." << VRJLUA_MSG_END(dbgVRJLUA_BUFFER, MSG_STATUS); for (unsigned int i = 0; i < n && !_buf.empty(); ++i) { { vpr::Guard<vpr::CondVar> guard(_cond, _runBlock); if (!guard.locked()) { VRJLUA_MSG_START(dbgVRJLUA_BUFFER, MSG_STATUS) << "Could not acquire buffer lock for consuming, done " "for this frame..." << VRJLUA_MSG_END(dbgVRJLUA_BUFFER, MSG_STATUS); return count; // won't do them out of order } current = _buf.front(); _buf.pop_front(); // Wake up anybody waiting for space _cond.signal(); guard.release(); } bool ret = _script.runString(current); if (!ret) { VRJLUA_MSG_START(dbgVRJLUA_BUFFER, MSG_ERROR) << "Could not execute this statement: " << current << VRJLUA_MSG_END(dbgVRJLUA_BUFFER, MSG_ERROR); } else { count++; } } return count; }
// PD_TRACE_DECLARE_FUNCTION ( SDB__RTNCONTEXTLOB_READ, "_rtnContextLob::read" ) INT32 _rtnContextLob::read( UINT32 len, SINT64 offset, _pmdEDUCB *cb ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY( SDB__RTNCONTEXTLOB_READ ) ; _readLen = len ; _offset = offset ; if ( -1 != _offset && _offset != _stream->curOffset() ) { _empty() ; /// clear data in context. rc = _stream->seek( _offset, cb ) ; if ( SDB_OK != rc ) { PD_LOG( PDERROR, "failed to seek lob:%d", rc ) ; goto error ; } } done: PD_TRACE_EXITRC( SDB__RTNCONTEXTLOB_READ, rc ) ; return rc ; error: goto done ; }
void merge(FibonacciHeap& other) { heap=_merge(heap,other.heap); other.heap=_empty(); }
FibonacciHeap() { heap=_empty(); }
int _height(np cur) { return _empty(cur) ? -1 : cur->height; }