1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 20:45:08 +00:00

LibCore: Add CThread, a simple thread abstraction object.

Currently this is only a simple wrapper around create_thread() that
remembers the thread ID of the spawned thread.
This commit is contained in:
Andreas Kling 2019-07-14 10:19:51 +02:00
parent ad7ec2bbc7
commit f1d6a37d5d
3 changed files with 48 additions and 0 deletions

View file

@ -0,0 +1,29 @@
#include <AK/Assertions.h>
#include <LibCore/CEventLoop.h>
#include <LibCore/CThread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
CThread& CThread::main_thread()
{
static CThread* main_thread;
if (!main_thread)
main_thread = new CThread(MainThread);
return *main_thread;
}
CThread::CThread(MainThreadTag)
: m_thread_id(0)
{
}
CThread::CThread(int (*entry)(void*), void* user_data)
{
ASSERT(entry);
m_thread_id = create_thread(entry, user_data);
}
CThread::~CThread()
{
}