ResourceBackgroundQueue Tutorial

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
Moohasha
Gnoll
Posts: 672
Joined: Fri Dec 07, 2007 7:37 pm

ResourceBackgroundQueue Tutorial

Post by Moohasha » Thu Dec 11, 2008 3:46 pm

Not really a "feature" request, but not really Help either. I would like to use ResourceBackgroundQueue to load resources in the background, but don't know how, and looking through the forums it looks like it's easy to make obvious mistakes trying to use it (like not compiling Ogre with OGRE_THREAD_SUPPORT defined.) It would be very helpful if there was a tutorial on the wiki or something about loading resources in the background.
Oh, I guess I do have a feature request. Enabling thread support shouldn't involve recompiling Ogre, as some people (like me) just download the binaries. It should either be a preprocessor definition that doesn't involve recompiling Ogre, or a function call at startup.
0 x
Black holes are where God divided by 0

scratchyrice
Gnome
Posts: 324
Joined: Thu Apr 27, 2006 9:14 pm
Location: United Kingdom - England

Re: ResourceBackgroundQueue Tutorial

Post by scratchyrice » Wed Dec 24, 2008 4:05 pm

I second this. Im currently in the procsess of learning to use background resources, So i may do a small guide my self. But we still should not have to recompile the whole libary to enable mutlithreading.
0 x
Intel I5 750 OC'd to 4.2Ghz per core, Geforce 580GTX 1.5Gb GPU, 280GTX for PhysX, 8Gb DDR 3 ram

User avatar
Azgur
Goblin
Posts: 264
Joined: Thu Aug 21, 2008 4:48 pm

Re: ResourceBackgroundQueue Tutorial

Post by Azgur » Fri Dec 26, 2008 10:44 am

scratchyrice wrote: But we still should not have to recompile the whole libary to enable mutlithreading.
It makes sense in a way. Threading will introduce locking at places where it wouldn't be needed otherwise.
This might be a small performance impact you wouldn't want if you're not using threading.

That's my guess at least.
0 x

User avatar
Moohasha
Gnoll
Posts: 672
Joined: Fri Dec 07, 2007 7:37 pm

Re: ResourceBackgroundQueue Tutorial

Post by Moohasha » Fri Dec 26, 2008 3:18 pm

Azgur wrote:It makes sense in a way. Threading will introduce locking at places where it wouldn't be needed otherwise.
You're right, but that's only if threading is enabled and you aren't using it. I'm talking about having some preprocessor definition in YOUR apps (rather than Ogre), or some function call that enables/disables threading, either at linkage or startup. Qt does this with a preprocessor. You have to #define QT_THREAD_SUPPORT in order to use the classes QThread and QMutex. You don't have to rebuild Qt.
I've looked at the source code, but not well enough to know how the threading works, but it sounds like there's one background thread to load resources, and all ResourceManagers have a mutex to make them thread safe, in which case it might be something as simple as:

Code: Select all

void ResourceManager::enableBackgroundLoading(bool enable)
{
     if (enable)
     {
          // Start background thread
          // Instanciate shared mutex
          // Anything else to support threading
     }
}
0 x
Black holes are where God divided by 0

Post Reply