mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-12 16:58:39 +00:00
Basic Lan Implmentation
This commit is contained in:
parent
bc23a610d3
commit
f03922f218
26 changed files with 1414 additions and 2 deletions
37
src/threading/thread_vector.h
Normal file
37
src/threading/thread_vector.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class thread_vector {
|
||||
public:
|
||||
std::vector<std::thread> workers;
|
||||
std::atomic_bool request_stop;
|
||||
|
||||
thread_vector(const std::string &name = "Unnamed", int priority = 0);
|
||||
virtual ~thread_vector();
|
||||
|
||||
virtual void func();
|
||||
|
||||
void reg (const std::string &name = "", int priority = 0);
|
||||
void start (const size_t n = 1);
|
||||
void restart (const size_t n = 1);
|
||||
void reanimate (const size_t n = 1);
|
||||
void stop ();
|
||||
void join ();
|
||||
|
||||
void sleep(const int second);
|
||||
// Thread compat:
|
||||
|
||||
bool stopRequested();
|
||||
bool isRunning();
|
||||
void wait();
|
||||
void kill();
|
||||
virtual void * run() = 0;
|
||||
bool isCurrentThread();
|
||||
protected:
|
||||
std::string m_name;
|
||||
int m_priority = 0;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue