123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #include "TickOrganizer.h"
- #include "Constants.h"
- TickOrganizer::TickOrganizer()
- : ReferenceCounter()
- {
- queue = new TickQueue();
- workerCount = NUM_TICK_WORKERS;
- workers = new TickWorker * [ workerCount ];
- for( int i = 0; i < workerCount; i++ )
- workers[ i ] = new TickWorker( queue );
- }
- TickOrganizer::~TickOrganizer()
- {
- queue->requestExit();
- for( int i = 0; i < workerCount; i++ )
- {
- workers[ i ]->warteAufThread( 10000 );
- workers[ i ]->ende();
- workers[ i ]->release();
- }
- queue->release();
- delete[] workers;
- }
- void TickOrganizer::nextTick()
- {
- bool waiting = 0;
- do
- {
- if( waiting )
- queue->waitForEmpty();
- for( int i = 0; i < workerCount; i++ )
- waiting |= workers[ i ]->isWaiting();
- } while( waiting );
- queue->startNextTick( &tickSources );
- }
- void TickOrganizer::addTickSource( Block *zBlock )
- {
- tickSources.add( zBlock );
- }
- void TickOrganizer::removeTickSource( Block *zBlock )
- {
- int index = 0;
- for( Framework::Iterator<Block *> it = tickSources.getIterator(); it; it++, index++ )
- {
- if( it == zBlock )
- {
- tickSources.remove( index );
- return;
- }
- }
- }
|