Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions skse64/Hooks_Threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,27 @@ void BSTaskPool::ProcessTasks()
{
CALL_MEMBER_FN(this, ProcessTaskQueue_HookTarget)();

// create temporary vector array to copy queue contents into
std::vector<TaskDelegate*> tasks_vector;

// copy queue contents until queue is empty (this is to prevent an infinite loop in some cases)
while (!IsTaskQueueEmpty())
{
s_taskQueueLock.Enter();
TaskDelegate * cmd = s_tasks.front();
TaskDelegate* cmd = s_tasks.front();
tasks_vector.push_back(cmd);
s_tasks.pop();
s_taskQueueLock.Leave();
}

// run copied delegates
for (TaskDelegate* cmd : tasks_vector) {
cmd->Run();
cmd->Dispose();
}
}

void TaskInterface::AddTask(TaskDelegate * cmd)
void TaskInterface::AddTask(TaskDelegate* cmd)
{
s_taskQueueLock.Enter();
s_tasks.push(cmd);
Expand All @@ -41,7 +49,7 @@ void TaskInterface::AddTask(TaskDelegate * cmd)

void Hooks_Threads_Init(void)
{

}

// 691ACD40B8430FBDA081477DEB2A9948ACC235F1+11F
Expand Down