Commit d91ca8e8 authored by David Reid's avatar David Reid

Resource Manager: Cleanup from some previous refactoring.

parent 0cbd8c2c
...@@ -2052,7 +2052,7 @@ static ma_data_source* ma_resource_manager_data_buffer_get_connector(ma_resource ...@@ -2052,7 +2052,7 @@ static ma_data_source* ma_resource_manager_data_buffer_get_connector(ma_resource
} }
} }
static ma_result ma_resource_manager_data_buffer_init_nolock(ma_resource_manager* pResourceManager, const char* pFilePath, ma_uint32 hashedName32, ma_uint32 flags, ma_resource_manager_memory_buffer* pExistingData, ma_async_notification* pNotification, ma_resource_manager_data_buffer* pDataBuffer) static ma_result ma_resource_manager_data_buffer_init_nolock(ma_resource_manager* pResourceManager, const char* pFilePath, ma_uint32 hashedName32, ma_uint32 flags, ma_async_notification* pNotification, ma_resource_manager_data_buffer* pDataBuffer)
{ {
ma_result result; ma_result result;
ma_resource_manager_data_buffer_node* pInsertPoint; ma_resource_manager_data_buffer_node* pInsertPoint;
...@@ -2123,27 +2123,10 @@ static ma_result ma_resource_manager_data_buffer_init_nolock(ma_resource_manager ...@@ -2123,27 +2123,10 @@ static ma_result ma_resource_manager_data_buffer_init_nolock(ma_resource_manager
} }
/* /*
The new data buffer has been inserted into the BST. If the data for the item is owned by the application we don't need to do anything except The new data buffer has been inserted into the BST. We now need to load the data. If we are loading synchronously we need to load
set the necessary data pointers. Otherwise we need to load the data. If we are loading synchronously we need to load everything from the everything from the calling thread because we may be in a situation where there are no job threads running and therefore the data
calling thread because we may be in a situation where there are no job threads running and therefore the data will never get loaded. If we will never get loaded. If we are loading asynchronously, we can assume at least one job thread exists and we can do everything
are loading asynchronously, we can assume at least one job thread exists and we can do everything from there. from there.
*/
if (pExistingData != NULL) {
/* We don't need to do anything if the data is owned by the application except set the necessary data pointers. */
MA_ASSERT(dataBufferType == pExistingData->type);
pDataBuffer->pNode->isDataOwnedByResourceManager = MA_FALSE;
pDataBuffer->pNode->data = *pExistingData;
pDataBuffer->pNode->result = MA_SUCCESS;
/* Fire the event if we have one. */
if (pNotification != NULL) {
ma_async_notification_signal(pNotification);
}
} else {
/*
The data needs to be loaded. If we're loading synchronously we need to do everything here on the calling thread. Otherwise we post
a job and get one of the job threads to do it for us.
*/ */
pDataBuffer->pNode->isDataOwnedByResourceManager = MA_TRUE; pDataBuffer->pNode->isDataOwnedByResourceManager = MA_TRUE;
pDataBuffer->pNode->result = MA_BUSY; pDataBuffer->pNode->result = MA_BUSY;
...@@ -2315,7 +2298,6 @@ static ma_result ma_resource_manager_data_buffer_init_nolock(ma_resource_manager ...@@ -2315,7 +2298,6 @@ static ma_result ma_resource_manager_data_buffer_init_nolock(ma_resource_manager
ma__free_from_callbacks(pDataBuffer->pNode, &pResourceManager->config.allocationCallbacks/*, MA_ALLOCATION_TYPE_RESOURCE_MANAGER_DATA_BUFFER*/); ma__free_from_callbacks(pDataBuffer->pNode, &pResourceManager->config.allocationCallbacks/*, MA_ALLOCATION_TYPE_RESOURCE_MANAGER_DATA_BUFFER*/);
return result; return result;
} }
}
/* It's not really necessary, but for completeness we'll want to fire the event if we have one in synchronous mode. */ /* It's not really necessary, but for completeness we'll want to fire the event if we have one in synchronous mode. */
if (async == MA_FALSE) { if (async == MA_FALSE) {
...@@ -2347,7 +2329,7 @@ MA_API ma_result ma_resource_manager_data_buffer_init(ma_resource_manager* pReso ...@@ -2347,7 +2329,7 @@ MA_API ma_result ma_resource_manager_data_buffer_init(ma_resource_manager* pReso
/* At this point we can now enter the critical section. */ /* At this point we can now enter the critical section. */
ma_mutex_lock(&pResourceManager->dataBufferLock); ma_mutex_lock(&pResourceManager->dataBufferLock);
{ {
result = ma_resource_manager_data_buffer_init_nolock(pResourceManager, pFilePath, hashedName32, flags, NULL, pNotification, pDataBuffer); result = ma_resource_manager_data_buffer_init_nolock(pResourceManager, pFilePath, hashedName32, flags, pNotification, pDataBuffer);
} }
ma_mutex_unlock(&pResourceManager->dataBufferLock); ma_mutex_unlock(&pResourceManager->dataBufferLock);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment