diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2024-01-19 17:29:58 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2024-01-25 02:39:05 +0200 |
commit | f422624d9c47b6f81c00d4b9fe2719b545b1392a (patch) | |
tree | 594e9841b5e70bfd2259769afffc10652f4a5284 /test/process/process_test.cpp | |
parent | d47fa37c2e22c0ef13be69c00950fe39f257e2bb (diff) |
libcamera: thread: Ensure deferred deletion of all objects before stopping
Objects can be scheduled for deletion with Object::deleteLater(), which
queues a deferred deletion to the thread's event loop. As the
deleteLater() function is meant to be called from a different thread,
this may race with thread termination, and deferred deletions queued
just before calling Thread::exit() may not be processed by the event
loop. Make sure they get processed when finishing the thread, before
stopping.
This eliminates the race condition that occurs when calling
Object::deleteLater() followed by Thread::exit() from the same thread.
Calling deleteLater() from neither the thread the object is bound to or
the thread calling Thread::exit() is still inherently racy.
The change fixes a failure in the object-delete unit test.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Diffstat (limited to 'test/process/process_test.cpp')
0 files changed, 0 insertions, 0 deletions