Files
core_misc/tjp/core/threads/Parallel.hpp
Timothy Prepscius fa54be052a flatten 20260225
2026-02-25 12:39:24 -05:00

45 lines
737 B
C++
Executable File

// 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