#include "Sincronizzatore.h" #include "Compito.h" Sincronizzatore::Sincronizzatore() : tempo_( 0 ) { } void Sincronizzatore::aggiungi( Compito * c ) { coda_.push( c ); } double Sincronizzatore::tempo() { return tempo_; } void Sincronizzatore::esegui() { while ( ! coda_.empty() ) { Compito* c = coda_.top(); coda_.pop(); tempo_ = c->tempoProssimoEvento(); bool attivo = c->esegui(); if ( attivo ) aggiungi( c ); } } bool Sincronizzatore::Comp::operator () ( Compito* c1, Compito* c2 ) { return ( c1->tempoProssimoEvento() > c2->tempoProssimoEvento() ); }