forked from Alepha/Alepha
47 lines
826 B
C++
47 lines
826 B
C++
static_assert( __cplusplus > 2020'99 );
|
|
|
|
#pragma once
|
|
|
|
#include <Alepha/Alepha.h>
|
|
|
|
#include "Thread.h"
|
|
|
|
namespace Alepha::Hydrogen ::detail:: ThreadGroup_m
|
|
{
|
|
inline namespace exports
|
|
{
|
|
class ThreadGroup;
|
|
}
|
|
|
|
class exports::ThreadGroup
|
|
{
|
|
private:
|
|
std::vector< std::unique_ptr< Thread > > threads;
|
|
|
|
public:
|
|
template< typename Function >
|
|
void
|
|
addThread( Function function )
|
|
{
|
|
// TODO: Exception handler wrapper
|
|
// TODO: lockstep start wrapper?
|
|
threads.push_back( std::make_unique< Thread >( std::forward< Function >( function ) ) );
|
|
}
|
|
|
|
void
|
|
join()
|
|
{
|
|
// TODO: Handle errors....
|
|
for( auto &thread: threads )
|
|
{
|
|
thread->join();
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
namespace Alepha::Hydrogen::inline exports::inline ThreadGroup_m
|
|
{
|
|
using namespace detail::ThreadGroup_m::exports;
|
|
}
|