count->isPaused()) { ++number:

Автор admin Пятница, 26 июня 2009 11:32

count->isPaused()) { ++number: { ostringstream os: os « *this « ” Total: ” « count->increment() « endl: display->output(os); } Thread::sleep(100): } waitingForCancel – true; while(!count->isCanceled()) // Задержка… Thread::sleep(100); ostringstream os: os « “Terminating ” « *this « endl: display->output(os): } int getValueO { while(count->isPaused() && IwaitingForCancel) Thread::sieep(100): return number; } friend ostream& operator«(ostream& os, const Entrances e) { return os « “Entrance ” « e.id « “: ” « e.number; } }: int mainO { srand(time(0)); // Раскрутка генератора случайных чисел cout « “Press to quit” « endl: CountedPtr count(new Count); vector v: CountedPtr display(new Display); const int SZ – 5; try { ThreadedExecutor executor; for(int i = 0; i < SZ: i++) { Entrance* task = new Entrance(count. display, i): executor.execute(task); // Сохранение указателя на задачу: v.push_back(task): } cin.getO; // Ждем, пока пользователь нажмет count->pause(); // Остановка подсчета int sum = 0; vector: iterator it = v.beginO; while(it != v.endO) { sum +=


Комментарии закрыты.