当前位置: 首页>>代码示例>>C++>>正文


C++ SharedMemNode类代码示例

本文整理汇总了C++中SharedMemNode的典型用法代码示例。如果您正苦于以下问题:C++ SharedMemNode类的具体用法?C++ SharedMemNode怎么用?C++ SharedMemNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SharedMemNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:LucyScott,项目名称:mdsplus,代码行数:25,代码来源:SharedDataManager.cpp

示例2: 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;
}
开发者ID:LucyScott,项目名称:mdsplus,代码行数:35,代码来源:SharedDataManager.cpp

示例3: clearCallback

 int SharedDataManager::clearCallback(TreeDescriptor treeId, int nid, char *callbackDescr)
{
	int status = 0;
	CallbackManager *callbackManager = (CallbackManager *)callbackDescr;
	callbackManager->dispose();
	lock.lock();
	SharedMemNode *retNode = sharedTree.find(treeId, nid);
	//Remove the CallbackManager instance from the queue associated with the nid node
	if(retNode)
	{
		CallbackManager *callbackManagerHead = retNode->getData()->getCallbackManager();
		if(callbackManagerHead == callbackManager)
			retNode->getData()->setCallbackManager(callbackManager->getNext());
		else
		{
			CallbackManager *next = callbackManager->getNext();
			CallbackManager *prev = callbackManager->getPrev();
			if(prev)
				prev->setNext((char *)next);
			if(next)
				next->setPrev((char *)prev);
		}
		allocationManager.deallocateShared((char *)callbackManager, sizeof(CallbackManager));
		status = 1;
	}
	lock.unlock();
	return status;
}
开发者ID:LucyScott,项目名称:mdsplus,代码行数:28,代码来源:SharedDataManager.cpp

示例4: 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;
	}
}
开发者ID:LucyScott,项目名称:mdsplus,代码行数:34,代码来源:SharedDataManager.cpp

示例5: discardData

int SharedDataManager::discardData(TreeDescriptor treeId, int nid)
{
	lock.lock();
	SharedMemNode *node = sharedTree.find(treeId, nid);
	if(node)
	{
		node->getData()->free(&allocationManager);
	}
	lock.unlock();
	return 1;
}
开发者ID:LucyScott,项目名称:mdsplus,代码行数:11,代码来源:SharedDataManager.cpp

示例6: 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;
}
开发者ID:LucyScott,项目名称:mdsplus,代码行数:14,代码来源:SharedDataManager.cpp

示例7: 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;
}
开发者ID:LucyScott,项目名称:mdsplus,代码行数:14,代码来源:SharedDataManager.cpp

示例8:

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;
}
开发者ID:LucyScott,项目名称:mdsplus,代码行数:18,代码来源:SharedDataManager.cpp

示例9: 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;
}
开发者ID:LucyScott,项目名称:mdsplus,代码行数:41,代码来源:SharedDataManager.cpp

示例10: 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;
	}
}
开发者ID:dgarnier,项目名称:MDSplus-forked,代码行数:41,代码来源:SharedDataManager.cpp

示例11: 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;
}
开发者ID:dgarnier,项目名称:MDSplus-forked,代码行数:21,代码来源:SharedDataManager.cpp

示例12: 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;
}
开发者ID:LucyScott,项目名称:mdsplus,代码行数:21,代码来源:SharedDataManager.cpp

示例13: 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;
}
开发者ID:LucyScott,项目名称:mdsplus,代码行数:21,代码来源:SharedDataManager.cpp

示例14: 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;
	}
}
开发者ID:LucyScott,项目名称:mdsplus,代码行数:23,代码来源:SharedDataManager.cpp

示例15: 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;
}
开发者ID:LucyScott,项目名称:mdsplus,代码行数:37,代码来源:SharedDataManager.cpp


注:本文中的SharedMemNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。