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:
parent
2d24860905
commit
c4130c589f
@ -171,7 +171,7 @@ public:
|
|||||||
void Process();
|
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)
|
void Enqueue(ThreadPoolItem * item)
|
||||||
{
|
{
|
||||||
@ -191,16 +191,18 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Take ownership
|
||||||
|
Item i{item};
|
||||||
// Perform the task in-place
|
// 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
|
// Task is completed in processing stage
|
||||||
item->OnCompleted();
|
m_Finished.enqueue(std::move(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user