hreadedExecutor.h” |include “z
Автор admin
Пятница, 26 июня 2009 11:32
hreadedExecutor.h” |include “zthread/CountedPtr.h” using namespace ZThread: using namespace std; class Count : public Cancelable { FastMutex lock; int count; bool paused, canceled; public: CountО : count (0), paused(false), canceled(false) {} int incrementО { // Если закомментировать следующую строку, подсчет перестает работать: Gua rd g(1ock); int temp = count ; if(rand() % 2 == 0) // Передача управления в половине случаев Thread::yield(): return (count = ++temp): } int valueO { Guard g(lock): return count: } void cancel О { Guard g(lock): canceled = true; } bool isCanceledO { Guard g(lock): return canceled: } bool pauseO { Guard g(lock): paused = true: } bool isPausedO { Guard g(lock); return paused; } }: class Entrance : public Runnable { CountedPtr count; CountedPtr display; int number: int id; bool waitingForCancel; public: Entrance(CountedPtr& cnt, CountedPtr& disp. int idn) : count(cnt). display(disp). id(idn). number(O), waitingForCancel(false) {} void run() { Завершение задач 561 } ///:- whileC!
Комментарии закрыты.
Последние комментарии