Remove use of pthread_cancel in the swapchain page flip thread
authorDennis Tsiang <dennis.tsiang@arm.com>
Fri, 1 May 2020 12:25:30 +0000 (13:25 +0100)
committerDennis Tsiang <dennis.tsiang@arm.com>
Fri, 1 May 2020 12:25:30 +0000 (13:25 +0100)
commit81544d04ae9804e69674fb279d63b3e1ad56138b
tree7d77f8d9486b46a03ffdfb7694b7b323da44c933
parent326234183937cc439203185276a9d7c62f96d005
Remove use of pthread_cancel in the swapchain page flip thread

The WSI layer may call pthread_cancel and kill the page flip
thread while it's still being used in Vulkan-API calls. This can cause the
layer to fail to clean up internal resources of the associated device,
leading to memory leaks. To resolve this, the layer now instead checks
if the page flip thread needs to end on every loop iteration. The
m_page_flip_semaphore has also been changed to a timed_semaphore to avoid
hanging indefinitely. In addition, m_page_flip_thread is now type
std::thread, which follows the gradual move towards C++ standard code
and moved to a private member function of the class.

Change-Id: Iefbdd0d68e1f92fdf79bcebb7eaf33429fc61fd3
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
wsi/swapchain_base.cpp
wsi/swapchain_base.hpp