2022-12-07 14:02:46 +00:00
|
|
|
#include "thread/Thread.h"
|
|
|
|
#include <luna/Alloc.h>
|
2022-12-17 09:50:49 +00:00
|
|
|
#include <luna/Atomic.h>
|
2022-12-07 14:02:46 +00:00
|
|
|
|
2022-12-17 09:50:49 +00:00
|
|
|
static Atomic<u64> g_next_id;
|
2022-12-07 14:02:46 +00:00
|
|
|
|
2022-12-19 11:43:23 +00:00
|
|
|
LinkedList<Thread> g_threads;
|
2022-12-07 14:02:46 +00:00
|
|
|
|
2022-12-17 09:50:49 +00:00
|
|
|
void Thread::init()
|
|
|
|
{
|
|
|
|
g_next_id = 1;
|
|
|
|
}
|
|
|
|
|
2022-12-07 14:02:46 +00:00
|
|
|
Result<Thread*> new_thread()
|
|
|
|
{
|
|
|
|
Thread* thread = TRY(make<Thread>());
|
|
|
|
|
|
|
|
thread->id = g_next_id++;
|
|
|
|
|
|
|
|
return thread;
|
2023-01-02 12:07:29 +00:00
|
|
|
}
|