Jump to content
  • Advertisement
Sign in to follow this  
The C modest god

File reading and multi threading

This topic is 4917 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 would like to read an animation file with two threads. One thread will read that data from the file into a system memory buffer and another thread will decode the buffer data. Do you think that will speed up the reading of an animation file? How do I create another thread that will run only a single function and after that will cease to exist. Do I need to worry about one thread reading from a variable that the second thread writes into?

Share this post


Link to post
Share on other sites
Advertisement
::CreateThread() is perfectly acceptable for a single function.

Yes, you have to worry about synchronization.

Yes, you can hide the disk latency using threading, so seeking the disk won't stop other things going on in your program.

Share this post


Link to post
Share on other sites
Do I have to call ExitThread or when the procedure, which I used at CreateThread, ends then the thread is terminated and I dont need to call any other function to close the thread?

Share this post


Link to post
Share on other sites
An alternative to using threading would be to implemention the overlapped IO supported by numerous platforms. I'm not sure about Linux, but if you use Windows, the CreateFile() and ReadFile() functions support overlapped IO, which lets you perform disk IO and be notified once the read is finished.

We use some version of asynchronous IO in all of our console & pc platforms. Abstracting async IO was easier then abstracting each platform's threaded model.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!