mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-03 16:18:51 -04:00
tma: first pass at TmaServiceManager
This commit is contained in:
parent
bb48e33074
commit
bf7dc84893
11 changed files with 595 additions and 22 deletions
|
@ -52,6 +52,11 @@ u32 TmaTaskList::GetNumSleepingTasks() const {
|
|||
return count;
|
||||
}
|
||||
|
||||
bool TmaTaskList::IsIdFree(u32 task_id) const {
|
||||
std::scoped_lock<HosMutex> lk(this->lock);
|
||||
return GetById(task_id) == nullptr;
|
||||
}
|
||||
|
||||
bool TmaTaskList::SendPacket(bool connected, TmaPacket *packet) {
|
||||
std::scoped_lock<HosMutex> lk(this->lock);
|
||||
|
||||
|
@ -112,6 +117,36 @@ bool TmaTaskList::ReceivePacket(TmaPacket *packet) {
|
|||
return task != nullptr;
|
||||
}
|
||||
|
||||
|
||||
void TmaTaskList::CleanupDoneTasks() {
|
||||
std::scoped_lock<HosMutex> lk(this->lock);
|
||||
|
||||
/* Clean up all tasks in Complete/Canceled state. */
|
||||
for (u32 i = 0; i < TmaTask::NumPriorities; i++) {
|
||||
auto it = this->tasks[i].begin();
|
||||
while (it != this->tasks[i].end()) {
|
||||
auto task = *it;
|
||||
switch (task->GetState()) {
|
||||
case TmaTaskState::InProgress:
|
||||
it++;
|
||||
break;
|
||||
case TmaTaskState::Complete:
|
||||
case TmaTaskState::Canceled:
|
||||
it = this->tasks[i].erase(it);
|
||||
if (task->GetOwnedByTaskList()) {
|
||||
delete task;
|
||||
} else {
|
||||
task->Signal();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* TODO: Panic to fatal? */
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TmaTaskList::Add(TmaTask *task) {
|
||||
std::scoped_lock<HosMutex> lk(this->lock);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue