| 108 | |
| 109 | |
| 110 | int main(int argc, char** argv) |
| 111 | { |
| 112 | int numThreads = 8; |
| 113 | |
| 114 | b3ThreadSupportInterface* threadSupport = createThreadSupport(numThreads); |
| 115 | |
| 116 | for (int i = 0; i < threadSupport->getNumTasks(); i++) |
| 117 | { |
| 118 | SampleThreadLocalStorage* storage = (SampleThreadLocalStorage*)threadSupport->getThreadLocalMemory(i); |
| 119 | b3Assert(storage); |
| 120 | storage->threadId = i; |
| 121 | } |
| 122 | |
| 123 | SampleArgs args; |
| 124 | args.m_cs = threadSupport->createCriticalSection(); |
| 125 | args.m_cs->setSharedParam(0, 100); |
| 126 | |
| 127 | int arg0, arg1; |
| 128 | int i; |
| 129 | for (i = 0; i < numThreads; i++) |
| 130 | { |
| 131 | threadSupport->runTask(B3_THREAD_SCHEDULE_TASK, (void*)&args, i); |
| 132 | } |
| 133 | |
| 134 | bool blockingWait = false; |
| 135 | if (blockingWait) |
| 136 | { |
| 137 | for (i = 0; i < numThreads; i++) |
| 138 | { |
| 139 | threadSupport->waitForResponse(&arg0, &arg1); |
| 140 | printf("finished waiting for response: %d %d\n", arg0, arg1); |
| 141 | } |
| 142 | } |
| 143 | else |
| 144 | { |
| 145 | int numActiveThreads = numThreads; |
| 146 | while (numActiveThreads) |
| 147 | { |
| 148 | if (threadSupport->isTaskCompleted(&arg0, &arg1, 0)) |
| 149 | { |
| 150 | numActiveThreads--; |
| 151 | printf("numActiveThreads = %d\n", numActiveThreads); |
| 152 | } |
| 153 | else |
| 154 | { |
| 155 | // printf("polling.."); |
| 156 | } |
| 157 | }; |
| 158 | } |
| 159 | |
| 160 | printf("stopping threads\n"); |
| 161 | |
| 162 | delete threadSupport; |
| 163 | printf("Press ENTER to quit\n"); |
| 164 | //getchar(); |
| 165 | return 0; |
| 166 | } |
nothing calls this directly
no test coverage detected