Hey! Yesterday I did some changes to the rendering process in Orbit. Previously I was using a Timer to trigger a frame rendering. Now I've introduced a background thread that triggers the rendering. So now Orbit is kinda multi-threaded when running. There are a few places where I use threading in Orbit, which I'm kinda happy about. Here's what we have:
- Application Thread (WinProc)
Main thread where all user input events and loading happens
- Rendering Thread
This thread is there just to call the Draw method. This allows me to update the screen gracefully while the app thread is busy with something else (like loading a loop)
- Thumbnails Thread
This is a intermittent thread. It exists only if the user has "Show Image Preview Thumbnails" in their config selected. It's a thread that's created for every loop that's loaded. It goes through the items in that new loop acquiring the thumbnails for items that support thumbnailing (Tasks and Image files). For some reason, on large folders, this thread is breaking and taking with it all thumbnail previews for the rest of the program lifetime. I have still to find out what it is. But generally, it works 100%.
And all of these threads coexist in various points of the program. With all these threads, Orbit ends up having a common base (the item registry) which can be simultaneously accessed and modified by three different threads earlier on this was quite confusing :) but now it's sorted :)
It's very common for the thumbnail and Rendering thread to share data. Like, everytime a thumbnail is acquired successfully in the thumb thread, it pops up an event (the item does, in fact) which changes a flag in the render thread demanding it to render the next frame (yes, Orbit only updates the screen if needed). I know it sounds pretty lame, but I'm quite happy about how it all works :)
Plus... With this background rendering... I was finally able to introduce loading indicators into Orbit (non transparent mode-only so far). So you know that Orbit's not dead :) and eventually, events get queued (clicking on one folder then clicking on another).
Aw well... Gotta study. Cheers!
Written by Lucas Menge on 06:51 PM
Send this message