[GD-General] worker threads, level loading and progress bars
Brought to you by:
vexxed72
From: <cas...@ya...> - 2002-08-07 02:21:55
|
Hi, to display a progress bar during the level loads, I've always used somekind of callback mechanism, or a simple 'DoWork' function that performs a little part of the work in each call and returns a special value when the work has been finished. Those approaches worked ok, but the progress of the bar wasn't smooth and the resulting code was not very clean: int DoWork( int prev_step ) { if( prev_step==0 ) { "do some work" return ++prev_step; } else if( prev_step==1 ) { ... } ... else return finish_step; } I've been thinking about moving to a multithreaded approach. This worked nicely until I tried to load textures, that of course didn't work because I had to create a new rendering context for the new thread. My system and specially the render was not designed with multithreading in mind, so I've noticed that this approach would need many changes in my current design. (creating multiple rendering context, locking and unlocking the render, etc.). Loading and uploading textures is almost half of the job, so unless I change my architecture, the threaded approach doesn't seem very usefull, since I still have to use the previous dirty work partition. Instead of using multiple threads I could also try to use the current method, but cleanly. For example by using an abstract job class, and a job queue that manages and process the pending jobs. Decomposing all the work in simple jobs, childs of the base job class and created by the job queue like in a parametrized factory. Queueing the jobs at the beginning and processing them secuentially on each 'DoWork' call. But before doing so, I would like to know what other people are doing. Thanks in advance, Ignacio Castaño cas...@ya... _______________________________________________________________ Yahoo! Messenger Nueva versión: Webcam, voz, y mucho más ¡Gratis! Descárgalo ya desde http://messenger.yahoo.es |