29 static void read_arrayrcp_in_thread(ArrayRCP<int> shared_arrayrcp,
30 int expectedValue, std::atomic<int> & countErrors) {
32 while (!ThreadTestManager::s_bAllowThreadsToRun) {}
33 for(
int n = 0;
n < 1000; ++
n) {
35 for (ArrayRCP<int>::const_iterator iter = shared_arrayrcp.begin();
36 iter < shared_arrayrcp.end(); ++iter) {
38 int readAValue = shared_arrayrcp[0];
40 if (readAValue != expectedValue) {
44 int readAValueByIterator = *iter;
46 if (readAValueByIterator != expectedValue) {
76 const int setValue = 67359487;
77 const int arraySize = 10;
78 std::atomic<int> countErrors(0);
80 for (
int testCycle = 0; testCycle < numTests; ++testCycle) {
81 std::vector<std::thread> threads;
83 ThreadTestManager::s_bAllowThreadsToRun =
false;
85 ArrayRCP<int> shared_arrayrcp(arraySize, setValue);
87 for (
int i = 0; i < numThreads; ++i) {
88 threads.push_back( std::thread(read_arrayrcp_in_thread,
89 shared_arrayrcp, setValue, std::ref(countErrors)));
92 ThreadTestManager::s_bAllowThreadsToRun =
true;
94 for (
unsigned int i = 0; i < threads.size(); ++i) {
97 convenience_log_progress(testCycle, numTests);
108 static void read_rcp_of_arrayrcp_in_thread(RCP<ArrayRCP<int>>
109 shared_rcp_of_arrayrcp,
int expectedValue, std::atomic<int> & countErrors) {
110 while (!ThreadTestManager::s_bAllowThreadsToRun) {}
111 for(
int n = 0;
n < 1000; ++
n) {
112 for (ArrayRCP<int>::const_iterator iter = shared_rcp_of_arrayrcp->begin();
113 iter < shared_rcp_of_arrayrcp->end(); ++iter) {
115 int readAValue = (*shared_rcp_of_arrayrcp)[0];
117 if (readAValue != expectedValue) {
121 int readAValueByIterator = *iter;
123 if (readAValueByIterator != expectedValue) {
148 const int setValue = 67359487;
149 const int arraySize = 10;
150 std::atomic<int> countErrors(0);
152 for (
int testCycle = 0; testCycle < numTests; ++testCycle) {
153 std::vector<std::thread> threads;
155 ThreadTestManager::s_bAllowThreadsToRun =
false;
157 RCP<ArrayRCP<int>> shared_rcp_of_arrayrcp =
158 rcp(
new ArrayRCP<int>(arraySize, setValue));
160 for (
int i = 0; i < numThreads; ++i) {
161 threads.push_back( std::thread(read_rcp_of_arrayrcp_in_thread,
162 shared_rcp_of_arrayrcp, setValue, std::ref(countErrors)) );
165 ThreadTestManager::s_bAllowThreadsToRun =
true;
167 for (
unsigned int i = 0; i < threads.size(); ++i) {
170 convenience_log_progress(testCycle, numTests);
Dangling reference error exception class.
RCP< T > rcp(const boost::shared_ptr< T > &sptr)
Conversion function that takes in a boost::shared_ptr object and spits out a Teuchos::RCP object...
#define TEUCHOS_THREAD_SAFE_UNIT_TESTS_THREADS_USED
#define TEST_EQUALITY(v1, v2)
Assert the equality of v1 and v2.
#define TEUCHOS_UNIT_TEST(TEST_GROUP, TEST_NAME)
Macro for defining a (non-templated) unit test.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)
Simple macro that catches and reports standard exceptions and other exceptions.
Smart reference counting pointer class for automatic garbage collection.
Reference-counted smart pointer for managing arrays.