uci-uav-forge / uavf_2024

Flight software for Student Unmanned Aerial Systems 2024 competition
MIT License
3 stars 0 forks source link

Multi-threaded Camera logging refactor #227

Closed MinhxNguyen7 closed 3 months ago

MinhxNguyen7 commented 3 months ago

Summary

Test Plan

Dat-Bois commented 3 months ago

I mean it looks fine, one issue I see is that it doesn't seem you are making a queue of the images to log. The reason I did this is because the image logging runs considerably slower than getting a live frame since its writing to disk. I know you have a threadpool to do it async but if its capped at 2 threads wouldn't that mean like we have a buffer of like 2?

What I'm describing you may have solved, it might just be my limited understanding of threadpools making it seem like what I described.

MinhxNguyen7 commented 3 months ago

The queue is implemented in the pool itself. You just need to submit to it. That's what makes it so elegant.

Dat-Bois commented 3 months ago

Right but isn't it only limited to two threads concurrently like you said? What happens if you want to log a frame while the other two threads are already occupied? Does the thread pool automatically hold the queue for 2+ requests?

MinhxNguyen7 commented 3 months ago

Yes. If you call submit 3 times simultaneously, the third one is added to the queue and executed after the 1st one is done.