Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/coro/semaphore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class semaphore
/**
* @return The maximum number of resources the semaphore can contain.
*/
[[nodiscard]] constexpr auto max() const noexcept -> std::ptrdiff_t { return max_value; }
[[nodiscard]] static constexpr auto max() noexcept -> std::ptrdiff_t { return max_value; }

/**
* The current number of resources available in this semaphore.
Expand Down
12 changes: 12 additions & 0 deletions test/test_semaphore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,18 @@ TEST_CASE("semaphore 1 producers and many consumers", "[semaphore]")
std::cerr << "END semaphore 1 producers and many consumers\n";
}

TEST_CASE("semaphore max()", "[semaphore]")
{
std::cerr << "BEGIN semaphore max()\n";

coro::semaphore<64> s{32};

REQUIRE(s.max() == 64);
REQUIRE(s.value() == 32);

std::cerr << "END semaphore max()\n";
}

TEST_CASE("~semaphore", "[semaphore]")
{
std::cerr << "[~semaphore]\n\n";
Expand Down
Loading