42 lines
832 B
C++
42 lines
832 B
C++
|
|
||
|
#include "clock_ab.h"
|
||
|
|
||
|
ClockAb::ClockAb(size_t myindex){
|
||
|
Glib::Mutex::Lock lock(_mutex);
|
||
|
printf("ClockAb::ClockAb -- constructor\n");
|
||
|
_cur_index = myindex;
|
||
|
_ticks = 0;
|
||
|
}
|
||
|
|
||
|
/*int numb, int myindex){
|
||
|
// lock jusqu'a la fin de la fonction
|
||
|
if ((myindex < 0) || (myindex > numb)) {
|
||
|
throw ClockInitError();
|
||
|
// throw exception
|
||
|
}
|
||
|
|
||
|
Glib::Mutex::Lock lock(_mutex);
|
||
|
|
||
|
_myidx = myindex;
|
||
|
for (int idx = 0; idx < numb; idx++){
|
||
|
//printf("ext vector %d\n",idx);
|
||
|
_ticks.push_back(0);
|
||
|
}
|
||
|
}*/
|
||
|
|
||
|
TimeStamp ClockAb::inc(){
|
||
|
// lock jusqu'a la fin de la fonction
|
||
|
Glib::Mutex::Lock lock(_mutex);
|
||
|
|
||
|
printf("ClockAb::inc -- creating timestamp\n");
|
||
|
_ticks++;
|
||
|
|
||
|
TimeStamp ts(Protocol::TYPE_ABCAST, _cur_index);
|
||
|
ts.push_back(_ticks);
|
||
|
return ts;
|
||
|
}
|
||
|
|
||
|
void ClockAb::adjust(TimeStamp ts){
|
||
|
printf("ClockAb::adjust -- NOT IMPLEMENTED\n");
|
||
|
}
|