2019-08-25 18:55:56 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Function.h>
|
2019-12-07 12:49:05 -07:00
|
|
|
#include <AK/String.h>
|
2019-08-25 18:55:56 +03:00
|
|
|
#include <LibCore/CObject.h>
|
|
|
|
|
|
|
|
namespace LibThread {
|
|
|
|
|
|
|
|
class Thread final : public CObject {
|
|
|
|
C_OBJECT(Thread);
|
|
|
|
|
|
|
|
public:
|
2019-12-07 12:49:05 -07:00
|
|
|
explicit Thread(Function<int()> action, StringView thread_name = nullptr);
|
2019-08-25 18:55:56 +03:00
|
|
|
virtual ~Thread();
|
|
|
|
|
|
|
|
void start();
|
|
|
|
void quit(int code = 0);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Function<int()> m_action;
|
|
|
|
int m_tid { -1 };
|
2019-12-07 12:49:05 -07:00
|
|
|
String m_thread_name;
|
2019-08-25 18:55:56 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|