View unanswered posts | View active topics It is currently Tue Jun 22, 2021 2:34 pm



Reply to topic  [ 3 posts ] 
 Multi-threaded file load 
Author Message

Joined: Thu Jan 06, 2011 12:55 pm
Posts: 6
Location: Sophia-Antipolis, France
Post Multi-threaded file load
Hi,

First of all, congrats for the nice work! I use GLC_lib to parse and show 3D models into an OpenGL application, and I have a suggestion.

I would like to be able to load several model files simultaneously, in separate threads. You can’t really do that with the current implementation (GLC_Factory::createWorldFromFile) because, the factory being unique by definition, you only have one source for the currentQuantum() signal. So you can’t properly monitor the file load progress.

To solve this issue, one would need to give access to one instance of a file loader object per file being loaded. Basically this means exporting the GLC_XXXToWorld classes, but with a common interface. Here is what I did :

Code:
class FileToWorld : public QObject
/* ... */
public:
    GLC_World createWorldFromFile(QFile & file, QStringList * attached = NULL);

signals:
    void      currentQuantum(int);
/* ... */
};


The implementation of FileToWorld::createWorldFromFile() is copied verbatim from the current GLC_Factory::createWorldFromFile() ; of course for this I need to include GLC_lib private headers :(

Then, I can instantiate one FileToWorld object per thread and therefore be notified of the progress of all my threads separately.

So, here is what I suggest: what about creating a new class, GLC_FileLoader (which would be more or less my FileToWorld class), and a new method in GLC_Factory to instantiate it? Like this:

Code:
GLC_FileLoader* GLC_Factory::createFileLoader(QFile &file);


What do you think? Thanks!

--
Jérôme


Thu Jan 06, 2011 2:27 pm
Profile
Site Admin

Joined: Sun Jan 03, 2010 4:27 pm
Posts: 390
Post Re: Multi-threaded file load
Hi,
jeromef wrote:
So, here is what I suggest: what about creating a new class, GLC_FileLoader (which would be more or less my FileToWorld class), and a new method in GLC_Factory to instantiate it?
What do you think? Thanks!

I think that's it's a very good :idea: idea :idea: :D :)
Thanks a lot !
If you want, you can send me you class ?
And If you have some other ideas like this one, you are welcome. ;)

Laurent.


Thu Jan 06, 2011 6:52 pm
Profile

Joined: Thu Jan 06, 2011 12:55 pm
Posts: 6
Location: Sophia-Antipolis, France
Post Re: Multi-threaded file load
laumaya wrote:
Hi,
jeromef wrote:
So, here is what I suggest: what about creating a new class, GLC_FileLoader (which would be more or less my FileToWorld class), and a new method in GLC_Factory to instantiate it?
What do you think? Thanks!

I think that's it's a very good :idea: idea :idea: :D :)
Thanks a lot !
If you want, you can send me you class ?
And If you have some other ideas like this one, you are welcome. ;)

Laurent.


OK, I will create a patch against GLC_lib trunk and send it to you :geek:
Cheers,

--
Jérôme


Fri Jan 07, 2011 9:48 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.