2026-05-27 16:03:38 +09:00
|
|
|
#ifndef __FISHBONE_THREAD_H__
|
|
|
|
|
#define __FISHBONE_THREAD_H__
|
|
|
|
|
|
|
|
|
|
namespace fishbone {
|
|
|
|
|
class Thread;
|
|
|
|
|
class Mutex;
|
|
|
|
|
}; // namespace fishbone
|
|
|
|
|
|
|
|
|
|
#include <fishbone/machdep.h>
|
|
|
|
|
|
|
|
|
|
namespace fishbone {
|
|
|
|
|
class Thread {
|
2026-05-27 21:36:15 +09:00
|
|
|
struct Impl;
|
|
|
|
|
Impl* impl;
|
2026-05-27 16:03:38 +09:00
|
|
|
|
|
|
|
|
public:
|
2026-05-28 18:04:14 +02:00
|
|
|
using Callable = void(*)(fishbone::Thread* thread, void* arg);
|
|
|
|
|
using CallableFunc = std::function<void(fishbone::Thread* thread)>;
|
|
|
|
|
|
|
|
|
|
Thread(Callable call, void* arg);
|
|
|
|
|
Thread(CallableFunc call);
|
2026-05-27 16:03:38 +09:00
|
|
|
~Thread();
|
|
|
|
|
|
|
|
|
|
void join();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Mutex {
|
2026-05-27 21:36:15 +09:00
|
|
|
struct Impl;
|
|
|
|
|
Impl* impl;
|
2026-05-27 16:03:38 +09:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
Mutex();
|
|
|
|
|
~Mutex();
|
|
|
|
|
|
2026-05-28 17:19:36 +02:00
|
|
|
Mutex(const Mutex&) = delete;
|
|
|
|
|
Mutex& operator=(const Mutex&) = delete;
|
|
|
|
|
|
2026-05-27 16:03:38 +09:00
|
|
|
void lock();
|
|
|
|
|
void unlock();
|
|
|
|
|
};
|
|
|
|
|
}; // namespace fishbone
|
|
|
|
|
|
|
|
|
|
#endif
|