Skip to content

Commit 65ecd01

Browse files
ThreadPool: allow task cancellation in EnqueueAsyncWork
1 parent eb9af01 commit 65ecd01

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Common/interface/ThreadPool.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ RefCntAutoPtr<IAsyncTask> EnqueueAsyncWork(IThreadPool* pThreadPool,
185185

186186
virtual void DILIGENT_CALL_TYPE Run(Uint32 ThreadId) override final
187187
{
188-
ASYNC_TASK_STATUS TaskStatus = m_Handler(ThreadId);
188+
ASYNC_TASK_STATUS TaskStatus = !m_bSafelyCancel.load() ?
189+
m_Handler(ThreadId) :
190+
ASYNC_TASK_STATUS_CANCELLED;
189191
SetStatus(TaskStatus);
190192
}
191193

0 commit comments

Comments
 (0)