// consumer.cc // Kenneth J. Goldman 12/26/94 // T. Paul McCartney 12/30/96 (converted) // // This module has a single writable integer presentation variable. // Whenever the value changes, it is printed to standard output. // The module quits if the value goes negative. #include #include "PG.hh" static int done = 0; class consumerReact : public PGreactor { public: virtual void react(PGvariable& v) { PGint& i = (PGint&)v; if (i < 0) done = 1; else cout << i << endl; }; }; int main() { PGint c = 0; consumerReact r; PG::initialize("CONSUMER"); c.publish("c", PG::WRITE); c.setReactor(&r); while (!done) PG::sleep(0, 200); PG::terminate(); }