mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-27 13:14:15 -04:00
strat: statically allocate additional threads
This commit is contained in:
parent
fbb5730369
commit
535e49a38d
17 changed files with 123 additions and 42 deletions
|
@ -22,8 +22,6 @@
|
|||
namespace sts::fatal::srv {
|
||||
|
||||
class ITask {
|
||||
public:
|
||||
static constexpr size_t DefaultStackSize = 0x1000;
|
||||
protected:
|
||||
const ThrowContext *context = nullptr;
|
||||
public:
|
||||
|
@ -32,14 +30,30 @@ namespace sts::fatal::srv {
|
|||
}
|
||||
|
||||
virtual Result Run() = 0;
|
||||
|
||||
virtual const char *GetName() const = 0;
|
||||
virtual u8 *GetStack() = 0;
|
||||
virtual size_t GetStackSize() const = 0;
|
||||
};
|
||||
|
||||
virtual size_t GetStackSize() const {
|
||||
return DefaultStackSize;
|
||||
template<size_t _StackSize>
|
||||
class ITaskWithStack : public ITask {
|
||||
public:
|
||||
static constexpr size_t StackSize = _StackSize;
|
||||
static_assert(util::IsAligned(StackSize, 0x1000), "StackSize alignment");
|
||||
protected:
|
||||
alignas(0x1000) u8 stack_mem[StackSize] = {};
|
||||
public:
|
||||
virtual u8 *GetStack() override final {
|
||||
return this->stack_mem;
|
||||
}
|
||||
|
||||
virtual size_t GetStackSize() const override final {
|
||||
return StackSize;
|
||||
}
|
||||
};
|
||||
|
||||
using ITaskWithDefaultStack = ITaskWithStack<0x2000>;
|
||||
|
||||
void RunTasks(const ThrowContext *ctx);
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue