2006-02-05 17:43:00 +00:00
|
|
|
|
|
|
|
|
|
#include "clock_cb.h"
|
|
|
|
|
|
|
|
|
|
ClockCb::ClockCb(size_t size, size_t index){
|
2006-03-04 14:24:03 +00:00
|
|
|
|
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);
|
|
|
|
|
}
|
2006-02-05 17:43:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClockCb::adjust(TimeStamp ts){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TimeStamp ClockCb::inc(){
|
2006-03-04 14:24:03 +00:00
|
|
|
|
// lock jusqu'a la fin de la fonction
|
|
|
|
|
Glib::Mutex::Lock lock(_mutex);
|
|
|
|
|
|
|
|
|
|
printf("ClockAb::inc -- creating timestamp\n");
|
|
|
|
|
// FIXME incr<63>menter le nombre de messages <20>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;
|
2006-02-05 17:43:00 +00:00
|
|
|
|
}
|