| 196 | } |
| 197 | |
| 198 | void test_threads(void) |
| 199 | { |
| 200 | NotifyBus bus("thread", 1024, 256); |
| 201 | |
| 202 | int e0 = bus.CreateEvent("thread0"); |
| 203 | int e1 = bus.CreateEvent("thread1"); |
| 204 | int e2 = bus.CreateEvent("thread2"); |
| 205 | int e3 = bus.CreateEvent("thread3"); |
| 206 | int count = 10; |
| 207 | |
| 208 | std::thread t0(echo_thread, count, &bus, e0, e1); |
| 209 | std::thread t1(echo_thread, count, &bus, e1, e2); |
| 210 | std::thread t2(echo_thread, count, &bus, e2, e3); |
| 211 | std::thread t3(echo_thread, count, &bus, e3, e0); |
| 212 | |
| 213 | // using furture and promise to get the quit of threads |
| 214 | |
| 215 | while(true) |
| 216 | bus.ProcessAllEvents(); |
| 217 | |
| 218 | t0.join(); |
| 219 | t1.join(); |
| 220 | t2.join(); |
| 221 | t3.join(); |
| 222 | } |
| 223 | |
| 224 | int main(void) |
| 225 | { |
no test coverage detected