diff --git a/ThreadGroup.h b/ThreadGroup.h new file mode 100644 index 0000000..9b69be6 --- /dev/null +++ b/ThreadGroup.h @@ -0,0 +1,46 @@ +static_assert( __cplusplus > 2020'99 ); + +#pragma once + +#include + +#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; +}