public Load ( string name, string group ) : Axiom.Core.Resource | ||
name | string | The name of the Resource |
group | string | The resource group to which this resource will belong |
return | Axiom.Core.Resource |
/// <see cref="WorkQueue.IResponseHandler.HandleResponse"/> ////[OgreVersion(1, 7, 2)] public void HandleResponse(WorkQueue.Response res, WorkQueue srcq) { if (res.Request.Aborted) { this.outstandingRequestSet.Remove(res.Request.ID); return; } if (res.Succeeded) { var resresp = (ResourceResponse)res.Data; // Complete full loading in main thread if semithreading ResourceRequest req = resresp.Request; #if AXIOM_THREAD_SUPPORT if (Configuration.Config.AxiomThreadLevel == 2) { // These load commands would have been downgraded to prepare() for the background if (req.Type == RequestType.LoadResource) { ResourceManager rm = ResourceGroupManager.Instance.ResourceManagers[req.ResourceType]; rm.Load(req.ResourceName, req.GroupName, req.IsManual, req.Loader, req.LoadParams, true); } else if (req.Type == RequestType.LoadGroup) { ResourceGroupManager.Instance.LoadResourceGroup(req.GroupName); } } #endif this.outstandingRequestSet.Remove(res.Request.ID); // Call resource listener if (resresp.Resource != null) { if (req.Type == RequestType.LoadResource) { resresp.Resource.FireLoadingComplete(true); } else { resresp.Resource.FirePreparingComplete(true); } } // Call queue listener if (req.Listener != null) { req.Listener.Invoke(res.Request.ID, req.Result); } } }
public virtual RequestID Load(string resType, string name, string group, bool isManual, IManualResourceLoader loader, NameValuePairList loadParams, OnOperationCompleted listener) #endif { #if AXIOM_THREAD_SUPPORT // queue a request ResourceRequest req = new ResourceRequest(); req.Type = RequestType.LoadResource; req.ResourceType = resType; req.ResourceName = name; req.GroupName = group; req.IsManual = isManual; req.Loader = loader; // Make instance copy of loadParams for thread independence req.LoadParams = (loadParams != null ? new NameValuePairList(loadParams) : null); req.Listener = listener; return(AddRequest(req)); #else // synchronous ResourceManager rm = ResourceGroupManager.Instance.ResourceManagers[resType]; rm.Load(name, group, isManual, loader, loadParams); return(0); #endif }
/// <see cref="WorkQueue.IRequestHandler.HandleRequest"/> //[OgreVersion(1, 7, 2)] public WorkQueue.Response HandleRequest(WorkQueue.Request req, WorkQueue srcQ) { var resreq = (ResourceRequest)req.Data; if (req.Aborted) { if (resreq.Type == RequestType.PrepareResource || resreq.Type == RequestType.LoadResource) { resreq.LoadParams.Clear(); resreq.LoadParams = null; } resreq.Result.Error = false; var resresp = new ResourceResponse(null, resreq); return(new WorkQueue.Response(req, true, resresp)); } ResourceManager rm = null; Resource resource = null; try { switch (resreq.Type) { case RequestType.InitializeGroup: ResourceGroupManager.Instance.InitializeResourceGroup(resreq.GroupName); break; case RequestType.InitializeAllGroups: ResourceGroupManager.Instance.InitializeAllResourceGroups(); break; case RequestType.PrepareGroup: ResourceGroupManager.Instance.PrepareResourceGroup(resreq.GroupName); break; case RequestType.LoadGroup: #if AXIOM_THREAD_SUPPORT if (Axiom.Configuration.Config.AxiomThreadLevel == 2) { ResourceGroupManager.Instance.PrepareResourceGroup(resreq.GroupName); } else { ResourceGroupManager.Instance.LoadResourceGroup(resreq.GroupName); } #endif break; case RequestType.UnloadGroup: ResourceGroupManager.Instance.UnloadResourceGroup(resreq.GroupName); break; case RequestType.PrepareResource: rm = ResourceGroupManager.Instance.ResourceManagers[resreq.ResourceType]; resource = rm.Prepare(resreq.ResourceName, resreq.GroupName, resreq.IsManual, resreq.Loader, resreq.LoadParams, true); break; case RequestType.LoadResource: #if AXIOM_THREAD_SUPPORT rm = ResourceGroupManager.Instance.ResourceManagers[resreq.ResourceType]; if (Axiom.Configuration.Config.AxiomThreadLevel == 2) { resource = rm.Prepare(resreq.ResourceName, resreq.GroupName, resreq.IsManual, resreq.Loader, resreq.LoadParams, true); } else { resource = rm.Load(resreq.ResourceName, resreq.GroupName, resreq.IsManual, resreq.Loader, resreq.LoadParams, true); } #endif break; case RequestType.UnloadResource: rm = ResourceGroupManager.Instance.ResourceManagers[resreq.ResourceType]; if (string.IsNullOrEmpty(resreq.ResourceName)) { rm.Unload(resreq.ResourceHandle); } else { rm.Unload(resreq.ResourceName); } break; } } catch (Exception e) { if (resreq.Type == RequestType.PrepareResource || resreq.Type == RequestType.LoadResource) { resreq.LoadParams.Clear(); resreq.LoadParams = null; } resreq.Result.Error = true; resreq.Result.Message = e.Message; //return error response var resresp = new ResourceResponse(resource, resreq); return(new WorkQueue.Response(req, false, resresp, e.Message)); } //success if (resreq.Type == RequestType.PrepareResource || resreq.Type == RequestType.LoadResource) { resreq.LoadParams.Clear(); resreq.LoadParams = null; } resreq.Result.Error = false; var resp = new ResourceResponse(resource, resreq); return(new WorkQueue.Response(req, true, resp)); }