From fbc731dec9d6322bfcb8f0d7dd31e8473ae6b3e0 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Wed, 27 Dec 2023 16:19:09 -0500 Subject: [PATCH] Thread Group (More needs to be done, but this is a start). --- ThreadGroup.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 ThreadGroup.h 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; +}