1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Update ThreadPool.hpp

This commit is contained in:
Sandu Liviu Catalin 2022-06-23 21:50:23 +03:00
parent 2d24860905
commit c4130c589f

View File

@ -171,7 +171,7 @@ public:
void Process();
/* --------------------------------------------------------------------------------------------
* Queue an item to be processed.
* Queue an item to be processed. Will take ownership of the given pointer!
*/
void Enqueue(ThreadPoolItem * item)
{
@ -191,16 +191,18 @@ public:
}
else
{
// Take ownership
Item i{item};
// Perform the task in-place
if (item->OnPrepare())
if (i->OnPrepare())
{
if (item->OnProcess())
if (i->OnProcess())
{
item->OnAborted(true); // Not accepted in single thread
i->OnAborted(true); // Not accepted in single thread
}
}
// Item was finished in main thread
item->OnCompleted();
// Task is completed in processing stage
m_Finished.enqueue(std::move(i));
}
}