63 static void read_arrayrcp_in_thread(ArrayRCP<int> shared_arrayrcp,
64 int expectedValue, std::atomic<int> & countErrors) {
66 while (!ThreadTestManager::s_bAllowThreadsToRun) {}
67 for(
int n = 0;
n < 1000; ++
n) {
69 for (ArrayRCP<int>::const_iterator iter = shared_arrayrcp.begin();
70 iter < shared_arrayrcp.end(); ++iter) {
72 int readAValue = shared_arrayrcp[0];
74 if (readAValue != expectedValue) {
78 int readAValueByIterator = *iter;
80 if (readAValueByIterator != expectedValue) {
110 const int setValue = 67359487;
111 const int arraySize = 10;
112 std::atomic<int> countErrors(0);
114 for (
int testCycle = 0; testCycle < numTests; ++testCycle) {
115 std::vector<std::thread> threads;
117 ThreadTestManager::s_bAllowThreadsToRun =
false;
119 ArrayRCP<int> shared_arrayrcp(arraySize, setValue);
121 for (
int i = 0; i < numThreads; ++i) {
122 threads.push_back( std::thread(read_arrayrcp_in_thread,
123 shared_arrayrcp, setValue, std::ref(countErrors)));
126 ThreadTestManager::s_bAllowThreadsToRun =
true;
128 for (
unsigned int i = 0; i < threads.size(); ++i) {
131 convenience_log_progress(testCycle, numTests);
142 static void read_rcp_of_arrayrcp_in_thread(RCP<ArrayRCP<int>>
143 shared_rcp_of_arrayrcp,
int expectedValue, std::atomic<int> & countErrors) {
144 while (!ThreadTestManager::s_bAllowThreadsToRun) {}
145 for(
int n = 0;
n < 1000; ++
n) {
146 for (ArrayRCP<int>::const_iterator iter = shared_rcp_of_arrayrcp->begin();
147 iter < shared_rcp_of_arrayrcp->end(); ++iter) {
149 int readAValue = (*shared_rcp_of_arrayrcp)[0];
151 if (readAValue != expectedValue) {
155 int readAValueByIterator = *iter;
157 if (readAValueByIterator != expectedValue) {
182 const int setValue = 67359487;
183 const int arraySize = 10;
184 std::atomic<int> countErrors(0);
186 for (
int testCycle = 0; testCycle < numTests; ++testCycle) {
187 std::vector<std::thread> threads;
189 ThreadTestManager::s_bAllowThreadsToRun =
false;
191 RCP<ArrayRCP<int>> shared_rcp_of_arrayrcp =
192 rcp(
new ArrayRCP<int>(arraySize, setValue));
194 for (
int i = 0; i < numThreads; ++i) {
195 threads.push_back( std::thread(read_rcp_of_arrayrcp_in_thread,
196 shared_rcp_of_arrayrcp, setValue, std::ref(countErrors)) );
199 ThreadTestManager::s_bAllowThreadsToRun =
true;
201 for (
unsigned int i = 0; i < threads.size(); ++i) {
204 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.