| 113 | } |
| 114 | |
| 115 | void SC::ThreadingTest::testMutex() |
| 116 | { |
| 117 | //! [mutexSnippet] |
| 118 | Mutex mutex; |
| 119 | int globalVariable = 0; |
| 120 | Thread thread1; |
| 121 | auto thread1Func = [&](Thread& thread) |
| 122 | { |
| 123 | thread.setThreadName(SC_NATIVE_STR("Thread1")); |
| 124 | mutex.lock(); |
| 125 | globalVariable++; |
| 126 | mutex.unlock(); |
| 127 | }; |
| 128 | SC_TEST_EXPECT(thread1.start(thread1Func)); |
| 129 | |
| 130 | Thread thread2; |
| 131 | auto thread2Func = [&](Thread& thread) |
| 132 | { |
| 133 | thread.setThreadName(SC_NATIVE_STR("Signaling2")); |
| 134 | mutex.lock(); |
| 135 | globalVariable++; |
| 136 | mutex.unlock(); |
| 137 | }; |
| 138 | SC_TEST_EXPECT(thread2.start(thread2Func)); |
| 139 | SC_TEST_EXPECT(thread1.join()); |
| 140 | SC_TEST_EXPECT(thread2.join()); |
| 141 | SC_TEST_EXPECT(globalVariable == 2); |
| 142 | //! [mutexSnippet] |
| 143 | } |
| 144 | |
| 145 | void SC::ThreadingTest::testRWLock() |
| 146 | { |
nothing calls this directly
no test coverage detected