void element::refine() { int longEdge, test; longEdge = findLongestEdge(); if (requestResponse) { // this element sent a special request and has received a response // from its neighbor; the neighbor performed half the refinement splitHelp(longEdge); // now finish the other half return; } if (specialRequest) { // my neighbor sent me a special request to refine if (getArea() < targetArea) { // no refinement necessary; accept request splitResponse(longEdge); // do my half of the refine return; } else { // refinement necessary if ((myRef.idx > specialRequester.idx) || ((myRef.idx == specialRequester.idx) && (myRef.cid > specialRequester.cid))) { // I have precedence; accept request splitResponse(longEdge); return; } else // requester has precedence; will send it special request shortly specialRequest = pendingRequest = 0; } } if (pendingRequest) // still awaiting a response; skip me return; // test longEdge relationship test = checkNeighbor(longEdge); if (test == -1) // long edge is on border splitBorder(longEdge); else if (test == 1) { // long edge is longest of both elements if (!edges[longEdge].locked(C)) splitNeighbors(longEdge); } else // long edge is not neighbor's long edge refineNeighbor(longEdge); }
void WsmProcessor::_handleEnumerateResponse( CIMResponseMessage* cimResponse, WsenEnumerateRequest* wsmRequest) { SoapResponse* soapResponse = 0; if (cimResponse->cimException.getCode() != CIM_ERR_SUCCESS) { _handleDefaultResponse(cimResponse, wsmRequest); return; } else { AutoMutex lock(_mutex); SharedPtr<WsenEnumerateResponse> wsmResponse( (WsenEnumerateResponse*) _cimToWsmResponseMapper. mapToWsmResponse(wsmRequest, cimResponse)); // Get the enumeration expiration time CIMDateTime expiration; _getExpirationDatetime(wsmRequest->expiration, expiration); // Create a new context Uint64 contextId = _currentEnumContext++; SharedPtr<EnumerationContext> enumContext(new EnumerationContext( contextId, wsmRequest->enumerationMode, expiration, wsmRequest->epr, wsmResponse)); _enumerationContextTable.insert(contextId, enumContext); wsmResponse->setEnumerationContext(contextId); // Get the requsted chunk of results AutoPtr<WsenEnumerateResponse> splitResponse( _splitEnumerateResponse(wsmRequest, wsmResponse.get(), wsmRequest->optimized ? wsmRequest->maxElements : 0)); splitResponse->setEnumerationContext(contextId); // If no items are left in the orignal response, mark split // response as complete if (wsmResponse->getSize() == 0) { splitResponse->setComplete(); } // Encode the response (enqueue it below). soapResponse = _wsmResponseEncoder.encode(splitResponse.get()); if (splitResponse->getSize() > 0) { // Add unprocessed items back to the context wsmResponse->merge(splitResponse.get()); } // Remove the context if there are no instances left if (wsmResponse->getSize() == 0) { _enumerationContextTable.remove(contextId); } } // Enqueue after unlocking the _enumerationContextTable to avoid deadlock. if (soapResponse) { _wsmResponseEncoder.sendResponse(soapResponse); delete soapResponse; } }