m2.mbcp/src/lowsender.cc

34 lines
684 B
C++
Raw Normal View History

2006-02-05 17:43:00 +00:00
2006-03-06 15:16:12 +00:00
#include <time.h>
#include "macros.h"
2006-02-05 17:43:00 +00:00
#include "lowsender.h"
2006-03-06 15:16:12 +00:00
#define DEBUG 0
2006-02-05 17:43:00 +00:00
#define MESSAGE "AB or CB cast from LowSender ? hehe...."
LowSender::LowSender(Group &grp, Clock &clk, Protocol::Type type) : _group(grp), _clock(clk), _type(type) {
}
void LowSender::run(){
// thread part
2006-03-06 15:16:12 +00:00
srand(time(NULL));
2006-02-05 17:43:00 +00:00
while(1){
sleep(3);
2006-03-06 15:16:12 +00:00
if (rand() % 3 == 0) {
printf("LowSender::run -- Broadcasting '%s'\n", MESSAGE);
TimeStamp ts = _clock.inc();
pDEBUG("Timestamp done\n");
Message msg(_type, ts, MESSAGE, strlen(MESSAGE));
pDEBUG("Mesg done and ready to send\n");
_group.broadcast(msg);
pDEBUG("Mesg sent\n");
} else {
pDEBUG("Not sending\n");
}
2006-02-05 17:43:00 +00:00
}
}