@CJha
@CJha said in Returning QReadLocker by value from a function?:
Are there any downsides to providing QReadLocker object as a return value from a function?
Yes. It won't work. semaphores are special kinds of objects. By design, they should never be copied.
Take simple counting semaphore. the count indicates whether a resource can acquire it. They are usually nothing more than an integer that is guaranteed atomic access. when you copy the integer the references are still to the old object, not the new one.
On a larger note, I think your whole model is kind of flawed. Don't "wrap" semaphores. Therein lies the introduction of race conditions. Use a reference to the sole instance of a semaphore anywhere it is needed.