fishbowl/engine/include/fishbone/thread.h

45 lines
742 B
C
Raw Normal View History

2026-05-27 16:03:38 +09:00
#ifndef __FISHBONE_THREAD_H__
#define __FISHBONE_THREAD_H__
2026-06-01 13:50:35 +09:00
#include <fishbone/pre.h>
2026-05-27 16:03:38 +09:00
namespace fishbone {
class Thread;
class Mutex;
}; // namespace fishbone
2026-06-01 13:50:35 +09:00
/* no includes */
2026-05-27 16:03:38 +09:00
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-29 14:23:50 +09:00
using Callable = void (*)(fishbone::Thread* thread, void* arg);
2026-05-29 01:10:45 +09:00
using CallableLambda = std::function<void(fishbone::Thread* thread)>;
2026-05-28 18:04:14 +02:00
Thread(Callable call, void* arg);
2026-05-29 01:10:45 +09:00
Thread(CallableLambda 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();
Mutex(const Mutex&) = delete;
Mutex& operator=(const Mutex&) = delete;
2026-05-27 16:03:38 +09:00
void lock();
void unlock();
};
}; // namespace fishbone
#endif