It is true that I’ll need some manual guarantees on terrain immutability, I can deal with it.
However, I need some way to guaranteely stop some work item.
Will code like this work as I expect?
With obviuos precondition that work item was added and wasn’t completed/removed.
It looks like I missed something…
/// Remove a work item if possible, otherwise complete executing. Return true if item was completed.
bool WorkQueue::DiscardWorkItem(SharedPtr<WorkItem> item)
{
if (RemoveWorkItem(item))
return false;
Resume();
while (!item->completed_)
{
}
item->sendEvent_ = false;
return true;
}