YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
unique_counter.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace yaclib::detail {
6
7template <typename CounterBase, typename Deleter = DefaultDeleter>
9 template <typename... Args>
10 OneCounter(std::size_t, Args&&... args) noexcept(std::is_nothrow_constructible_v<CounterBase, Args&&...>)
11 : CounterBase{std::forward<Args>(args)...} {
12 }
13
14 constexpr bool SubEqual(std::size_t) const {
15 return false;
16 }
17
18 // compiler remove this call from code
19 void Add(std::size_t) noexcept { // LCOV_EXCL_LINE
20 } // LCOV_EXCL_LINE
21
22 void Sub(std::size_t) noexcept {
23 Deleter::Delete(*this);
24 }
25};
26
27} // namespace yaclib::detail
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25
OneCounter(std::size_t, Args &&... args) noexcept(std::is_nothrow_constructible_v< CounterBase, Args &&... >)
void Sub(std::size_t) noexcept
constexpr bool SubEqual(std::size_t) const
void Add(std::size_t) noexcept