Skip to content
Open
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
1 change: 1 addition & 0 deletions Development/nmos/mutex.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef NMOS_MUTEX_H
#define NMOS_MUTEX_H

#include <mutex> //for std::unique_lock
#include "bst/shared_mutex.h"

namespace nmos
Expand Down
12 changes: 6 additions & 6 deletions Development/nmos/test/condition_variable_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "bst/test/test.h"

namespace
namespace test_condition_variable
{
struct test_model
{
Expand Down Expand Up @@ -89,27 +89,27 @@ namespace
////////////////////////////////////////////////////////////////////////////////////////////
BST_TEST_CASE(testConditionVariableWait)
{
const auto max_threads{ 500 };
const int max_threads{ 500 };

// start a wait thread
std::thread wait_thread(wait);
std::thread wait_thread(test_condition_variable::wait);

// start a large number of lock_then_unlock threads to exhaust the lock limit
std::vector<std::thread> threads;
for (auto idx = 0; idx < max_threads; idx++)
{
threads.push_back(std::thread(lock_then_unlock));
threads.push_back(std::thread(test_condition_variable::lock_then_unlock));
}

// send a lot of notifications to wake up the wait thread
// to wake the wait thread when lock limit is exhausted
for (auto idx = 0; idx < 100; idx++)
{
model.notify();
test_condition_variable::model.notify();
}

// start the thread to pause 1 second before signal a shutdown
std::thread shutdown_thread(shutdown, std::chrono::seconds{ 1 });
std::thread shutdown_thread(test_condition_variable::shutdown, std::chrono::seconds{ 1 });

shutdown_thread.join();
wait_thread.join();
Expand Down
Loading