예제 #1
0
void SharedDataManager::setWarm(TreeDescriptor treeId, int nid, bool warm)
{
	lock.lock();
	SharedMemNodeData *nodeData = getNodeData(treeId, nid, true);
	if(nodeData)
		nodeData->setWarm(warm);
	lock.unlock();
}
예제 #2
0
 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;
	}
}