The assertion that actions were previously under lock is incorrect. See:
21 - lk.unlock();
22 - exec(surface.get());
So this proposal does not change the locking behaviour at all.
I need this because I'm in a situation where I want each MirBufferStream to hold a weak reference to the MirSurface(s) that use it. This is required to implement client-side vsync where the clock to sync the stream's swapping to is dictated by which output the window (MirSurface) is on.
So MirBufferStream (or anything in future) wants to hold a weak_ptr to its MirSurface(s). Presently we can only store raw pointers, which is unsafe because there's no guarantee the toolkit will always destroy its streams before its surfaces. Using a shared_ptr (or weak_ptr in my case) avoids such risk. And as mentioned above the locking semantics are unchanged.
Admittedly I can work around all this and move forward in my other work but it would be a hack. What I propose here is the cleanest solution and a generally nice to have simplification.
It should also be noted this is not a new idea. It's already used in:
The assertion that actions were previously under lock is incorrect. See:
21 - lk.unlock(); get());
22 - exec(surface.
So this proposal does not change the locking behaviour at all.
I need this because I'm in a situation where I want each MirBufferStream to hold a weak reference to the MirSurface(s) that use it. This is required to implement client-side vsync where the clock to sync the stream's swapping to is dictated by which output the window (MirSurface) is on.
So MirBufferStream (or anything in future) wants to hold a weak_ptr to its MirSurface(s). Presently we can only store raw pointers, which is unsafe because there's no guarantee the toolkit will always destroy its streams before its surfaces. Using a shared_ptr (or weak_ptr in my case) avoids such risk. And as mentioned above the locking semantics are unchanged.
Admittedly I can work around all this and move forward in my other work but it would be a hack. What I propose here is the cleanest solution and a generally nice to have simplification.
It should also be noted this is not a new idea. It's already used in:
174 virtual std::shared_ ptr<MirBuffer> buffer(int buffer_id) const = 0;