#include "clock_cb.h" ClockCb::ClockCb(size_t size, size_t index){ Glib::Mutex::Lock lock(_mutex); printf("ClockCb::ClockCb -- constructor\n"); _cur_index = index; //_ticks = 0; // lock jusqu'a la fin de la fonction if ((index < 0) || (index > size)) { throw ClockInitError(); // throw exception } for (int idx = 0; idx < size; idx++){ printf ("ClockCb::ClockCb -- extending vector to %d\n", idx); _ticks.push_back (0); } } void ClockCb::adjust(TimeStamp ts){ } TimeStamp ClockCb::inc(){ // lock jusqu'a la fin de la fonction Glib::Mutex::Lock lock(_mutex); printf("ClockAb::inc -- creating timestamp\n"); // FIXME incrémenter le nombre de messages émis localement. _ticks[_cur_index] = _ticks[_cur_index] + 1; TimeStamp ts(Protocol::TYPE_CBCAST, _cur_index); // on push tous les ticks de l'horloge for (int idx = 0; idx < _ticks.size(); idx++){ printf ("ClockCb::ClockCb -- adding %d to timestamp\n", idx); ts.push_back (_ticks.at(idx)); } return ts; }