flatten 20260225
This commit is contained in:
44
tjp/core/threads/Parallel.hpp
Executable file
44
tjp/core/threads/Parallel.hpp
Executable file
@@ -0,0 +1,44 @@
|
||||
// TJP COPYRIGHT HEADER
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Parallel.h"
|
||||
#include <thread>
|
||||
|
||||
#include <tjp/core/threads/Lock.hpp>
|
||||
#include <tjp/core/threads/Atomic.h>
|
||||
#include <tjp/core/threads/TestMutex.hpp>
|
||||
#include <tjp/core/containers/Function.hpp>
|
||||
|
||||
namespace tjp::core::threads {
|
||||
|
||||
struct Parallel
|
||||
{
|
||||
size_t n;
|
||||
std::thread *threads;
|
||||
|
||||
using F = Function<void(size_t n, size_t m)>;
|
||||
F f;
|
||||
|
||||
[[no_unique_address]]
|
||||
TestMutex oneUser;
|
||||
|
||||
Event event;
|
||||
Event::Mutex mutex;
|
||||
bool running = false;
|
||||
|
||||
using Signal = u128;
|
||||
static constexpr Signal SignalBit = 1;
|
||||
Signal signal = 0;
|
||||
|
||||
Parallel(int max, int free);
|
||||
~Parallel();
|
||||
|
||||
void start(int max, int free);
|
||||
void execute(size_t n, size_t m);
|
||||
void run(F &&f_);
|
||||
void stop();
|
||||
|
||||
} ;
|
||||
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user