mirror of
https://gitlab.com/niansa/cosched.git
synced 2025-03-06 20:53:26 +01:00
Resource deadlock avoided
This commit is contained in:
parent
a95878f505
commit
32bfe1dbac
1 changed files with 3 additions and 1 deletions
|
@ -13,9 +13,9 @@ void ScheduledThread::main_loop() {
|
||||||
std::unique_lock L(queue_mutex);
|
std::unique_lock L(queue_mutex);
|
||||||
while (!queue.empty()) {
|
while (!queue.empty()) {
|
||||||
// Get queue entry
|
// Get queue entry
|
||||||
L.lock();
|
|
||||||
auto e = std::move(queue.front());
|
auto e = std::move(queue.front());
|
||||||
queue.pop();
|
queue.pop();
|
||||||
|
// Unlock queue
|
||||||
L.unlock();
|
L.unlock();
|
||||||
// Create task for it
|
// Create task for it
|
||||||
sched.create_task(e.task_name);
|
sched.create_task(e.task_name);
|
||||||
|
@ -23,6 +23,8 @@ void ScheduledThread::main_loop() {
|
||||||
auto& start_fcn = std::any_cast<decltype(e.start_fcn)&>(Task::get_current().properties.emplace("start_function", std::move(e.start_fcn)).first->second);
|
auto& start_fcn = std::any_cast<decltype(e.start_fcn)&>(Task::get_current().properties.emplace("start_function", std::move(e.start_fcn)).first->second);
|
||||||
// Call start function
|
// Call start function
|
||||||
start_fcn();
|
start_fcn();
|
||||||
|
// Lock queue
|
||||||
|
L.lock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Run once
|
// Run once
|
||||||
|
|
Loading…
Add table
Reference in a new issue