Archived

This topic is now archived and is closed to further replies.

Reentrancy in Resource Management. Yuck.

This topic is 5040 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m attempting to write a resource manager for my engine. An unexpected problem has arisen out of the necessity of certain resources to load other resources. Basically, resource management is handled by a Singleton (used to be a Monostate; they''re exactly the same in operation). When the function GetHandle is called, the manager checks to see if the resource has been loaded, and if so, increments the ref count on the resource and returns a handle to it. If the resource is NOT found, it loads it, increments refs, and then returns a handle. The methods of dereferencing and releasing aren''t particularly important to the discussion, though the solution will necessarily manage both recursive loading and releasing. The problem arises when, for example, a material file needs a handle to a texture. In the current system, the material creation function will call the resource manager''s GetHandle function and attempt to load the function that instant. However, GetHandle is already invoked for the creation of the material resource. This isn''t a problem in itself, but there are certain static members of the class (unique ID counter, etc.) that are not able to handle reentrance robustly. My objective is to create a system that handles immediate recursive resource loading, but I don''t have any idea how to go about it, and that''s what I''m asking about. I would prefer not to do any of the following: 1) Abandon the static variables, replacing them with some sort of GUID or LUID generator. 2) Create a cache, stack, queue, or any other sort of deferred loading mechanism. The need will ultimately arise for a robust recursive solution somewhere. 3) Add a level of indirection in the form of a resource server that caches incoming requests (very similar to 2). Any suggestions, patterns, or methods you can suggest are most welcome. Thanks for your time. Peace, ZE. //email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

Share this post


Link to post
Share on other sites