mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:48:14 +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:
parent
ad7ec2bbc7
commit
f1d6a37d5d
3 changed files with 48 additions and 0 deletions
18
Libraries/LibCore/CThread.h
Normal file
18
Libraries/LibCore/CThread.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
class CThread {
|
||||
public:
|
||||
static CThread& main_thread();
|
||||
|
||||
CThread(int (*entry)(void*), void* user_data);
|
||||
~CThread();
|
||||
|
||||
bool is_main_thread() const { return m_thread_id == 0; }
|
||||
int thread_id() const { return m_thread_id; }
|
||||
|
||||
private:
|
||||
enum MainThreadTag { MainThread };
|
||||
explicit CThread(MainThreadTag);
|
||||
|
||||
int m_thread_id { -1 };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue