Corrected ClockCb

This commit is contained in:
glenux 2006-03-04 14:24:03 +00:00
parent c0bad9b9bc
commit 749807ec3f
6 changed files with 32 additions and 23 deletions

View file

@ -10,6 +10,7 @@ dabcast_SOURCES = \
group.cc \
lowreceiver.cc \
lowreceiver_ab.cc \
lowreceiver_cb.cc \
lowsender.cc \
highreceiver.cc \
message.cc \

View file

@ -8,22 +8,6 @@ ClockAb::ClockAb(size_t 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);

View file

@ -2,11 +2,38 @@
#include "clock_cb.h"
ClockCb::ClockCb(size_t size, size_t index){
printf("ClockCb::ClockCb -- create\n");
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;
}

View file

@ -79,7 +79,7 @@ Config::Config(int argc, char **argv) {
{
HostId g_host;
string optstr(optarg);
///stringstream s_host, s_port;
stringstream s_host, s_port;
int idx = optstr.find(":");
if (idx > 0){

View file

@ -40,11 +40,11 @@ int main(int argc, char ** argv){
printf("Test mode!\n");
break;
case Protocol::TYPE_ABCAST:
clk = new ClockAb(config.getIndex());
clk = new ClockAb (config.getIndex());
printf("AbCast mode!\n");
break;
case Protocol::TYPE_CBCAST:
clk = new ClockCb(4,1);
clk = new ClockCb (grp.getCount(), config.getIndex());
printf("CbCast mode!\n");
break;
case Protocol::TYPE_UNKNOWN:

View file

@ -104,6 +104,3 @@ void LowReceiver::manage(Message * mesg){
}
}
void LowReceiver::manage_cbcast(Message * mesg) {
printf("LowReceiver::manage_cbcast -- init\n");
}