9 #ifndef FAIR_MQ_TOOLS_INSTANCELIMIT_H
10 #define FAIR_MQ_TOOLS_INSTANCELIMIT_H
14 namespace fair::mq::tools
17 template<
typename Tag,
int Max>
18 struct InstanceLimiter
20 InstanceLimiter() { Increment(); }
21 explicit InstanceLimiter(
const InstanceLimiter&) =
delete;
22 explicit InstanceLimiter(InstanceLimiter&&) =
delete;
23 InstanceLimiter& operator=(
const InstanceLimiter&) =
delete;
26 auto GetCount() ->
int {
return fCount; }
29 auto Increment() ->
void
34 throw std::runtime_error(
35 ToString(
"More than ", Max,
" instances of ", Tag(),
" in parallel not supported"));
39 auto Decrement() ->
void
49 template<
typename Tag,
int Max>
50 int InstanceLimiter<Tag, Max>::fCount(0);