本文整理汇总了C++中SharedMemNodeData类的典型用法代码示例。如果您正苦于以下问题:C++ SharedMemNodeData类的具体用法?C++ SharedMemNodeData怎么用?C++ SharedMemNodeData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SharedMemNodeData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSegmentData
int SharedDataManager::getSegmentData(TreeDescriptor treeId, int nid, int idx, char **dim, int *dimSize, char **data, int *dataSize,
char **shape, int *shapeSize, int *currDataSize, bool *timestamped, int *actSamples)
{
Segment *segment;
lock.lock();
SharedMemNode *node = sharedTree.find(treeId, nid);
if(node)
{
SharedMemNodeData *nodeData = node->getData();
if(!nodeData->isSegmented())
{
lock.unlock();
return 0;
}
int numSegments = nodeData->getNumSegments();
if(idx >= numSegments || idx < 0)
{
lock.unlock();
return 0;
}
segment = nodeData->getSegmentAt(idx);
segment->getDim((char **)dim, dimSize);
segment->getData((char **)data, dataSize);
segment->getShape((char **)shape, shapeSize);
*currDataSize = segment->getCurrDataSize();
*timestamped = segment->isTimestamped();
*actSamples = segment->getActSamples();
lock.unlock();
return 1;
}
lock.unlock();
return 0;
}
示例2: getSegmentInfo
int SharedDataManager::getSegmentInfo(TreeDescriptor treeIdx, int nid, int idx, int **shape, int *shapeSize, int *currDataSize)
{
Segment *segment;
lock.lock();
SharedMemNode *node = sharedTree.find(treeIdx, nid);
if(node)
{
SharedMemNodeData *nodeData = node->getData();
if(!nodeData->isSegmented())
{
lock.unlock();
return 0;
}
int numSegments = nodeData->getNumSegments();
if(idx >= numSegments)
idx = numSegments - 1;
segment = nodeData->getSegmentAt(idx);
segment->getShape(reinterpret_cast<char **>(shape), shapeSize);
*currDataSize = segment->getCurrDataSize();
lock.unlock();
return 1;
}
lock.unlock();
return 0;
}
示例3: getNodeData
////////////////////////////////////////////////
//Cache coerency methods
////////////////////////////////////////////////
void SharedDataManager::getCoherencyInfo(TreeDescriptor treeId, int nid, bool &isOwner, int &ownerIdx, bool &isWarm, bool &isDirty, int ×tamp)
{
lock.lock();
SharedMemNodeData *nodeData = getNodeData(treeId, nid, true);
if(nodeData)
nodeData->getCoherencyInfo(isOwner, ownerIdx, isWarm, isDirty, timestamp);
lock.unlock();
}
示例4: isSegmented
int SharedDataManager::isSegmented(TreeDescriptor treeId, int nid, int *segmented)
{
lock.lock();
SharedMemNode *node = sharedTree.find(treeId, nid);
if(node)
{
SharedMemNodeData *nodeData = node->getData();
*segmented = nodeData->isSegmented()?1:0;
lock.unlock();
return 1;
}
lock.unlock();
return 0;
}
示例5: getNumSegments
int SharedDataManager::getNumSegments(TreeDescriptor treeId, int nid, int *numSegments)
{
lock.lock();
SharedMemNode *node = sharedTree.find(treeId, nid);
if(node)
{
SharedMemNodeData *nodeData = node->getData();
*numSegments = nodeData->getNumSegments();
lock.unlock();
return 1;
}
lock.unlock();
return 0;
}
示例6:
SharedMemNodeData *SharedDataManager::getNodeData(TreeDescriptor treeId, int nid, bool create)
{
SharedMemNode *node;
node = sharedTree.find(treeId, nid);
if(node)
return node->getData();
if(create)
{
SharedMemNodeData nodeData;
nodeData.setNid(treeId, nid);
sharedTree.insert(&nodeData);
node = sharedTree.find(treeId, nid);
return node->getData();
}
return 0;
}
示例7: void
void *SharedDataManager::setCallback(TreeDescriptor treeId, int nid, void *argument, void (*callback)(int, void *))
{
char *retPtr = NULL;
int status = 0;
lock.lock();
SharedMemNode *retNode = sharedTree.find(treeId, nid);
if(!retNode)
//No data has been written in the cache yet, or the not is not cacheable,
//then create a nid node without data
{
SharedMemNodeData nodeData;
nodeData.setNid(treeId, nid);
sharedTree.insert(&nodeData, &lock);
retNode = sharedTree.find(treeId, nid);
}
if(retNode)
{
//Create a new Callback manager and concatenate it to the linked list of Callback managers
//associated with this nid node
CallbackManager *callbackManager = (CallbackManager *)freeSpaceManager.allocateShared(sizeof(CallbackManager), &lock);
CallbackManager *prevCallbackManager = retNode->getData()->getCallbackManager();
if(prevCallbackManager)
prevCallbackManager->setPrev((char *)callbackManager);
callbackManager->setNext((char *)retNode->getData()->getCallbackManager());
callbackManager->setPrev(NULL);
retNode->getData()->setCallbackManager(callbackManager);
callbackManager->initialize(nid, argument, callback);
SharedMemNodeData *nodeData = retNode->getData();
nodeData->setWarm(true);
lock.unlock();
return callbackManager;
}
else
{
lock.unlock();
return NULL;
}
}
示例8: getSegmentLimits
int SharedDataManager::getSegmentLimits(TreeDescriptor treeId, int nid, int idx, char **start, int *startSize,
char **end, int *endSize, bool *timestamped)
{
Segment *segment;
lock.lock();
SharedMemNode *node = sharedTree.find(treeId, nid);
if(node)
{
SharedMemNodeData *nodeData = node->getData();
if(!nodeData->isSegmented())
{
lock.unlock();
return 0;
}
int numSegments = nodeData->getNumSegments();
if(idx >= numSegments || idx < 0)
{
lock.unlock();
return 0;
}
segment = nodeData->getSegmentAt(idx);
if(segment->isTimestamped())
{
*timestamped = true;
segment->getStartTimestamp(start, startSize);
segment->getEndTimestamp(end, endSize);
}
else
{
segment->getStart((char **)start, startSize);
segment->getEnd((char **)end, endSize);
*timestamped = false;
}
lock.unlock();
return 1;
}
lock.unlock();
return 0;
}
示例9: discardFirstSegment
int SharedDataManager::discardFirstSegment(TreeDescriptor treeId, int nid)
{
//printf("START DISCARD\n");
lock.lock();
SharedMemNode *node = sharedTree.find(treeId, nid);
if(node)
{
SharedMemNodeData *nodeData = node->getData();
if(!nodeData->isSegmented())
{
lock.unlock();
return 0;
}
nodeData->discardFirstSegment(&allocationManager);
lock.unlock();
//printf("END DISCARD\n");
return 1;
}
lock.unlock();
return 0;
}
示例10: discardOldSegments
int SharedDataManager::discardOldSegments(TreeDescriptor treeId, int nid, _int64 timestamp)
{
//printf("START DISCARD\n");
lock.lock();
SharedMemNode *node = sharedTree.find(treeId, nid);
if(node)
{
SharedMemNodeData *nodeData = node->getData();
if(!nodeData->isSegmented())
{
lock.unlock();
return 0;
}
nodeData->discardOldSegments(timestamp, &freeSpaceManager, &lock);
lock.unlock();
//printf("END DISCARD\n");
return 1;
}
lock.unlock();
return 0;
}
示例11: findSegment
int SharedDataManager::findSegment(TreeDescriptor treeId, int nid, int *retIdx)
{
int numSegments;
lock.lock();
SharedMemNode *node = sharedTree.find(treeId, nid);
if(node)
{
SharedMemNodeData *nodeData = node->getData();
numSegments = nodeData->getNumSegments();
if(numSegments == 0)
{
lock.unlock();
return 0; //No segments
}
*retIdx = numSegments - 1;
lock.unlock();
return 1;
}
return 0;
}
示例12: setData
int SharedDataManager::setData(TreeDescriptor treeId, int nid, char dataType, int numSamples, char *data, int size) //Write data indexed by nid
{
lock.lock();
SharedMemNode *node = sharedTree.find(treeId, nid);
if(!node)
//No data has been written in the cache yet
{
SharedMemNodeData nodeData;
nodeData.setNid(treeId, nid);
sharedTree.insert(&nodeData);
node = sharedTree.find(treeId, nid);
}
if(node)
{
SharedMemNodeData *nodeData = node->getData() ;
nodeData->free(&allocationManager);
char *currData = allocationManager.allocateShared(size);
memcpy(currData, data, size);
nodeData->setData((char *)currData, size);
nodeData->setDataInfo(dataType, numSamples);
CallbackManager *callback = node->getData()->getCallbackManager();
if(callback)
callback->callCallback();
lock.unlock();
return 1;
}
else
{
lock.unlock();
return 0;
}
}
示例13: getData
int SharedDataManager::getData(TreeDescriptor treeId, int nid, char *dataType, int *numSamples, char **data, int *size) //Write data indexed by nid
{
lock.lock();
SharedMemNode *node = sharedTree.find(treeId, nid);
if(node)
{
SharedMemNodeData *nodeData = node->getData();
if(nodeData->isSegmented())
{
lock.unlock();
return 0;
}
nodeData->getData((char **)data, size);
nodeData->getDataInfo(dataType, numSamples);
lock.unlock();
return 1;
}
else
{
lock.unlock();
return 0;
}
}
示例14: getSegmentDataAndShapeCopy
int SharedDataManager::getSegmentDataAndShapeCopy(TreeDescriptor treeId, int nid, int idx, char **data, int *dataSize,
char **shape, int *shapeSize)
{
Segment *segment;
lock.lock();
SharedMemNode *node = sharedTree.find(treeId, nid);
if(node)
{
SharedMemNodeData *nodeData = node->getData();
if(!nodeData->isSegmented())
{
lock.unlock();
return 0;
}
int numSegments = nodeData->getNumSegments();
if(idx >= numSegments || idx < 0)
{
lock.unlock();
return 0;
}
segment = nodeData->getSegmentAt(idx);
char *currData;
segment->getData((char **)&currData, dataSize);
*data = new char[*dataSize];
memcpy(*data, currData,*dataSize);
char *currShape;
segment->getShape((char **)&currShape, shapeSize);
*shape = new char[*shapeSize];
memcpy(*shape, currShape, *shapeSize);
lock.unlock();
return 1;
}
lock.unlock();
return 0;
}
示例15: setSerializedData
void SharedDataManager::setSerializedData(TreeDescriptor treeId, int nid, char *serializedData, int dataLen)
{
lock.lock();
SharedMemNode *node = sharedTree.find(treeId, nid);
if(!node)
//No data has been written in the cache yet
{
SharedMemNodeData nodeData;
nodeData.setNid(treeId, nid);
sharedTree.insert(&nodeData);
node = sharedTree.find(treeId, nid);
}
if(node)
{
SharedMemNodeData *nodeData = node->getData();
nodeData->free(&allocationManager);
nodeData->initialize(serializedData, &allocationManager);
CallbackManager *callback = node->getData()->getCallbackManager();
if(callback)
callback->callCallback();
}
lock.unlock();
}