So, I have been looking into making my Album application call ffmpeg asynchronously, via smol + async-process. Currently, I use ffmpeg to generate lightweight 100x100 jpeg thumbnails for photo and video files.
The app displays these thumbnails in a GtkGridView, so the GtkImages are inside GtkListItems. This means there is a factory generating these widgets, so the code to call ffmpeg / fetch thumbnails from cache is called within a GtkSignalListItemFactory bind signal handler.
Even though I have prepped all the thumbnail code to be async, I reached a bit of a ‘dead end’ with what scope of the program runs asynchronously. Since these calls are made within a GTK signal handler (which is a closure given as a callback) I cannot make the closure itself asynchronous. To start executing with an asynchronous runtime, there will always be a “block_on” function call that blocks the current thread until completion. So, this means that I cannot manufacture these list items asynchronously, only async within each list item manufactured, which blocks the thread each time, which defeats the purpose.
Hopefully the above made sense. Any help is appreciated.
You can also read over the source of my application below: