mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-08 05:01:44 +00:00
meso: KProcess: add ForEachThread
This commit is contained in:
parent
240f455bc0
commit
2efdee5cb8
2 changed files with 24 additions and 0 deletions
|
@ -46,7 +46,20 @@ class KProcess final : public KSynchronizationObject /* FIXME */ {
|
|||
void SetDebug(KDebug *debug);
|
||||
void ClearDebug(State attachState);
|
||||
|
||||
template<typename F, typename ...Args>
|
||||
void ForEachThread(F f, Args &&...args)
|
||||
{
|
||||
std::scoped_lock s{mutex};
|
||||
std::scoped_lock s2{threadingMutex};
|
||||
|
||||
for (KThread &t : threadList) {
|
||||
f(t, std::forward(args)...);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
KThread::ProcessList threadList{};
|
||||
|
||||
KThread *lastThreads[MAX_CORES]{nullptr};
|
||||
ulong lastIdleSelectionCount[MAX_CORES]{0};
|
||||
long schedulerOperationCount = -1;
|
||||
|
@ -57,6 +70,8 @@ class KProcess final : public KSynchronizationObject /* FIXME */ {
|
|||
KDebug *debug = nullptr;
|
||||
SharedPtr<KResourceLimit> reslimit{};
|
||||
KHandleTable handleTable{};
|
||||
|
||||
mutable KMutex mutex{}, threadingMutex{};
|
||||
};
|
||||
|
||||
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(Process);
|
||||
|
|
|
@ -17,8 +17,10 @@ struct LightSessionRequest;
|
|||
|
||||
struct KThreadContext;
|
||||
|
||||
struct ThreadProcessListTag;
|
||||
struct ThreadWaitListTag;
|
||||
struct ThreadMutexWaitListTag;
|
||||
using ThreadProcessListBaseHook = boost::intrusive::list_base_hook<boost::intrusive::tag<ThreadProcessListTag> >;
|
||||
using ThreadWaitListBaseHook = boost::intrusive::list_base_hook<boost::intrusive::tag<ThreadWaitListTag> >;
|
||||
using ThreadMutexWaitListBaseHook = boost::intrusive::list_base_hook<boost::intrusive::tag<ThreadMutexWaitListTag> >;
|
||||
|
||||
|
@ -27,6 +29,7 @@ class KThread final :
|
|||
public ILimitedResource<KThread>,
|
||||
public ISetAllocated<KThread>,
|
||||
public IAlarmable,
|
||||
public ThreadProcessListBaseHook,
|
||||
public ThreadWaitListBaseHook,
|
||||
public ThreadMutexWaitListBaseHook
|
||||
{
|
||||
|
@ -106,6 +109,12 @@ class KThread final :
|
|||
KernelLoading = 4,
|
||||
};
|
||||
|
||||
|
||||
using ProcessList = typename boost::intrusive::make_list<
|
||||
KThread,
|
||||
boost::intrusive::base_hook<ThreadProcessListBaseHook>
|
||||
>::type;
|
||||
|
||||
using SchedulerList = typename boost::intrusive::make_list<
|
||||
KThread,
|
||||
boost::intrusive::value_traits<KThread::SchedulerValueTraits>
|
||||
|
|
Loading…
Reference in a new issue