MCPcopy Create free account
hub / github.com/3rdparty/libprocess / Client

Class Client

src/tests/benchmarks.cpp:417–448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

415
416
417class Client : public Process<Client>
418{
419public:
420 Client(const UPID& destination, CountDownLatch* latch, long repeat)
421 : destination(destination), latch(latch), repeat(repeat) {}
422
423protected:
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
442private:
443 UPID destination;
444 CountDownLatch* latch;
445 long repeat;
446 long sent = 0L;
447 long received = 0L;
448};
449
450
451// See

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected