PM: Refactor for R_TRY, remove gotos

This commit is contained in:
Michael Scire 2019-06-17 15:27:29 -07:00
parent c60ee15449
commit ee40dcd76f
15 changed files with 126 additions and 165 deletions

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <mutex>
#include <switch.h>
@ -23,27 +23,27 @@
class ProcessWaiter final : public IWaitable {
public:
std::shared_ptr<Registration::Process> process;
ProcessWaiter(std::shared_ptr<Registration::Process> p) : process(p) {
/* ... */
}
std::shared_ptr<Registration::Process> GetProcess() {
return this->process;
std::shared_ptr<Registration::Process> GetProcess() {
return this->process;
}
/* IWaitable */
/* IWaitable */
Handle GetHandle() override {
return this->process->handle;
}
Result HandleSignaled(u64 timeout) override {
return Registration::HandleSignaledProcess(this->GetProcess());
}
};
class ProcessList final {
private:
private:
HosRecursiveMutex m;
HosRecursiveMutex *GetMutex() {
@ -51,15 +51,15 @@ class ProcessList final {
}
public:
std::vector<std::shared_ptr<Registration::Process>> processes;
void lock() {
GetMutex()->lock();
}
void unlock() {
GetMutex()->unlock();
}
void try_lock() {
GetMutex()->try_lock();
}