| 252 | } |
| 253 | |
| 254 | void TestMessageBus_3() |
| 255 | { |
| 256 | Mama ma(true); |
| 257 | Child tom(true, string("Tom"), string("Delicious!")); |
| 258 | Child rose(true, string("Rose"), string("Just so so!")); |
| 259 | Child jean(true, string("Jean"), string("Terrible!")); |
| 260 | cout << "0==================================================" << endl; |
| 261 | ma.Cooking(); |
| 262 | cout << "1==================================================" << endl; |
| 263 | while(!g_amsgbus.MessageEmpty()) |
| 264 | { |
| 265 | g_amsgbus.ProcessOneMessage(); |
| 266 | } |
| 267 | cout << "2==================================================" << endl; |
| 268 | ma.Cooking(); |
| 269 | cout << "3==================================================" << endl; |
| 270 | g_amsgbus.ProcessAllMessage(); |
| 271 | cout << "4==================================================" << endl; |
| 272 | { |
| 273 | Timer tm; |
| 274 | #if 1 |
| 275 | int64_t i = 0; |
| 276 | while(i++ < 100000L) |
| 277 | { |
| 278 | ma.Cooking(); |
| 279 | g_amsgbus.ProcessAllMessage(); |
| 280 | } |
| 281 | #else |
| 282 | std::shared_future<void> task = std::async(std::launch::async /*deferred*/, // std::launch::async |
| 283 | test_async_1, &ma /*, &tom, &rose, &jean*/ |
| 284 | ); |
| 285 | task.get(); |
| 286 | #endif |
| 287 | cerr << 100000L * 1000 / tm.elapsed_ms() << "times/s\n"; |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | int main() |
| 292 | { |