mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-24 05:11:14 +00:00
8cb77ac136
namespace sts::ams -> ams::exosphere, ams::. This is to facilitate future use of ams:: namespace code in mesosphere, as we'll want to include ams::util, ams::result, ams::svc...
77 lines
2.6 KiB
C++
77 lines
2.6 KiB
C++
/*
|
|
* Copyright (c) 2018-2019 Atmosphère-NX
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms and conditions of the GNU General Public License,
|
|
* version 2, as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* 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 <stratosphere.hpp>
|
|
|
|
namespace ams::os::impl {
|
|
|
|
class WaitableObjectList;
|
|
class WaitableManagerImpl;
|
|
|
|
class WaitableHolderBase {
|
|
public:
|
|
util::IntrusiveListNode manager_node;
|
|
util::IntrusiveListNode object_list_node;
|
|
private:
|
|
WaitableManagerImpl *manager = nullptr;
|
|
public:
|
|
/* Gets whether the held waitable is currently signaled. */
|
|
virtual TriBool IsSignaled() const = 0;
|
|
/* Adds to manager's object list, returns is signaled. */
|
|
virtual TriBool LinkToObjectList() = 0;
|
|
/* Removes from the manager's object list. */
|
|
virtual void UnlinkFromObjectList() = 0;
|
|
/* Gets handle to output, returns INVALID_HANDLE on failure. */
|
|
virtual Handle GetHandle() const = 0;
|
|
/* Gets the amount of time remaining until this wakes up. */
|
|
virtual u64 GetWakeupTime() const {
|
|
return U64_MAX;
|
|
}
|
|
|
|
/* Interface with manager. */
|
|
void SetManager(WaitableManagerImpl *m) {
|
|
this->manager = m;
|
|
}
|
|
|
|
WaitableManagerImpl *GetManager() const {
|
|
return this->manager;
|
|
}
|
|
|
|
bool IsLinkedToManager() const {
|
|
return this->manager != nullptr;
|
|
}
|
|
};
|
|
|
|
class WaitableHolderOfUserObject : public WaitableHolderBase {
|
|
public:
|
|
/* All user objects have no handle to wait on. */
|
|
virtual Handle GetHandle() const override {
|
|
return INVALID_HANDLE;
|
|
}
|
|
};
|
|
|
|
class WaitableHolderOfKernelObject : public WaitableHolderBase {
|
|
public:
|
|
/* All kernel objects have native handles, and thus don't have object list semantics. */
|
|
virtual TriBool LinkToObjectList() override {
|
|
return TriBool::Undefined;
|
|
}
|
|
virtual void UnlinkFromObjectList() override {
|
|
/* ... */
|
|
}
|
|
};
|
|
|
|
}
|