| 415 | |
| 416 | |
| 417 | class Client : public Process<Client> |
| 418 | { |
| 419 | public: |
| 420 | Client(const UPID& destination, CountDownLatch* latch, long repeat) |
| 421 | : destination(destination), latch(latch), repeat(repeat) {} |
| 422 | |
| 423 | protected: |
| 424 | void consume(MessageEvent&& event) override |
| 425 | { |
| 426 | if (event.message.name == "pong") { |
| 427 | received += 1; |
| 428 | if (sent < repeat) { |
| 429 | send(destination, "ping"); |
| 430 | sent += 1; |
| 431 | } else if (received >= repeat) { |
| 432 | latch->decrement(); |
| 433 | } |
| 434 | } else if (event.message.name == "run") { |
| 435 | for (long l = 0; l < std::min(1000L, repeat); l++) { |
| 436 | send(destination, "ping"); |
| 437 | sent += 1; |
| 438 | } |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | private: |
| 443 | UPID destination; |
| 444 | CountDownLatch* latch; |
| 445 | long repeat; |
| 446 | long sent = 0L; |
| 447 | long received = 0L; |
| 448 | }; |
| 449 | |
| 450 | |
| 451 | // See |
nothing calls this directly
no outgoing calls
no test coverage detected