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


C++ SharedMemNodeData::free方法代码示例

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


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

示例1: 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, &lock);
		node = sharedTree.find(treeId, nid);
	}
	if(node)
	{
		SharedMemNodeData *nodeData = node->getData() ;
		nodeData->free(&freeSpaceManager, &lock);

		char *currData = freeSpaceManager.allocateShared(size, &lock);
		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:dgarnier,项目名称:MDSplus-forked,代码行数:34,代码来源:SharedDataManager.cpp

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

示例3: beginTimestampedSegment

int SharedDataManager::beginTimestampedSegment(TreeDescriptor treeId, int nid, int idx, int numItems, char *shape, 
											   int shapeSize, char *data, int dataSize, _int64 start, 
											   _int64 end, char *dim, int dimSize, int *retIdx)
{
	Segment *segment;
//printf("BEGIN TIMESTAMPED SEGMENT SHARE: %d\n", *(int *)shape);
	lock.lock();
	SharedMemNode *node = sharedTree.find(treeId, nid);
	if(!node)
	{
		SharedMemNodeData nodeData;
		nodeData.setNid(treeId, nid);
		nodeData.setSegmented(true);
		sharedTree.insert(&nodeData);
		node = sharedTree.find(treeId, nid);
	}

	if(node)
	{
		SharedMemNodeData *nodeData = node->getData();
		if(!nodeData->isSegmented())
		{
			nodeData->free(&allocationManager);
			nodeData->setSegmented(true);
		}
		int numSegments = nodeData->getNumSegments();
		if(idx > numSegments)
		{
			lock.unlock();
			return 0;
		}
		if(idx == numSegments || idx < 0)
		{
			segment = (Segment *)allocationManager.allocateShared(sizeof(Segment));
			
//			printf("ALLOCATED SEGMENT: %x\n", segment);
			
			segment->initialize();
			nodeData->appendSegment(segment);
			*retIdx = numSegments;
		}
		else
		{
			segment = nodeData->getSegmentAt(idx);
			*retIdx = idx;
		}

		char *currPtr;
		segment->free(&allocationManager);

		if(dimSize == 0)
		{
			currPtr = allocationManager.allocateShared(8 * numItems);
//			printf("ALLOCATED SEGMENT DIM: %x\n", currPtr);
			segment->setDim(currPtr, 8 * numItems);
		}
		currPtr = allocationManager.allocateShared(shapeSize);
//			printf("ALLOCATED SEGMENT SHAPE: %x  %d\n", currPtr, *(int *)shape);
		memcpy(currPtr, shape, shapeSize);
		segment->setShape(currPtr, shapeSize);

		currPtr = allocationManager.allocateShared(dataSize);
//			printf("ALLOCATED SEGMENTDATA: %x\n", currPtr);
		memcpy(currPtr, data, dataSize);
		segment->setData(currPtr, dataSize);
	
		//The following parameters are meaningful only when copying a segment from the tree into cache
		segment->setStartTimestamp(start);
		segment->setEndTimestamp(end);
		if(dimSize > 0)
		{
			currPtr = allocationManager.allocateShared(dimSize);
//			printf("ALLOCATED SEGMENT DIM : %x\n", currPtr);
			memcpy(currPtr, dim, dimSize);
			segment->setDim(currPtr, dimSize);
			segment->setStartTimestamp(*(_int64 *)dim);
			if(end == 0) segment->setEndTimestamp(*(_int64 *)dim);
		}
		segment->setTimestamped(true);

		lock.unlock();
//printf("END BEGIN TIMESTAMPED SEGMENT LAST SEGMENT: %x\n", nodeData->getLastSegment());
		return 1;
	}
	lock.unlock();
	return 0;
}
开发者ID:LucyScott,项目名称:mdsplus,代码行数:87,代码来源:SharedDataManager.cpp

示例4: beginSegment

int SharedDataManager::beginSegment(TreeDescriptor treeId, int nid, int idx, char *start, int startSize, char *end, int endSize, 
			char *dim, int dimSize, char *shape, int shapeSize, char *data, int dataSize, int *retIdx)
{
	Segment *segment;
	lock.lock();
	SharedMemNode *node = sharedTree.find(treeId, nid);
	if(!node)
	{
		SharedMemNodeData nodeData;
		nodeData.setNid(treeId, nid);
		nodeData.setSegmented(true);
		sharedTree.insert(&nodeData);
		node = sharedTree.find(treeId, nid);
	}

	if(node)
	{
		SharedMemNodeData *nodeData = node->getData();
		if(!nodeData->isSegmented())
		{
			nodeData->free(&allocationManager);
			nodeData->setSegmented(true);
		}
		int numSegments = nodeData->getNumSegments();
		if(idx > numSegments)
		{
			lock.unlock();
			return 0;
		}
		if(idx == numSegments || idx < 0)
		{
			segment = (Segment *)allocationManager.allocateShared(sizeof(Segment));
			segment->initialize();
			nodeData->appendSegment(segment);
			*retIdx = numSegments;
		}
		else
		{
			segment = nodeData->getSegmentAt(idx);
			*retIdx = idx;
		}

		char *currPtr;
		segment->free(&allocationManager);

		currPtr = allocationManager.allocateShared(startSize);
		memcpy(currPtr, start, startSize);
		segment->setStart(currPtr, startSize);

		currPtr = allocationManager.allocateShared(endSize);
		memcpy(currPtr, end, endSize);
		segment->setEnd(currPtr, endSize);

		currPtr = allocationManager.allocateShared(dimSize);
		memcpy(currPtr, dim, dimSize);
		segment->setDim(currPtr, dimSize);

		currPtr = allocationManager.allocateShared(shapeSize);
		memcpy(currPtr, shape, shapeSize);
		segment->setShape(currPtr, shapeSize);

		currPtr = allocationManager.allocateShared(dataSize);
		memcpy(currPtr, data, dataSize);
		segment->setData(currPtr, dataSize);

		segment->setTimestamped(false);

		lock.unlock();
		return 1;
	}
	lock.unlock();
	return 0;
}
开发者ID:LucyScott,项目名称:mdsplus,代码行数:73,代码来源:SharedDataManager.cpp


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