Files
2014-06-30 13:58:10 +02:00

87 lines
1.8 KiB
C++

/*
* File: NextViewBuffer.h
* Author: stubbfel
*
* Created on 14. August 2013, 21:23
*/
#ifndef NEXTVIEWBUFFER_H
#define NEXTVIEWBUFFER_H
#include "common/MoversightService.h"
#include "common/Defines.h"
#include "common/container/List.h"
#include "mt/msg/MulticastMessage.h"
#include "ms/PeerState.h"
namespace ubeeme {
namespace moversight {
class Dispatcher;
class MulticastMessage;
class MoversightMessageTyp;
class ViewChangeEvent;
class JoinGroupDoneEvent;
/**
* @class NextViewBuffer
* @author Felix Stubbe
* @ingroup Moversight
* @brief Buffer stores and "replay" MutlicastMessages
*/
class NextViewBuffer : public MoversightService {
public:
typedef List<MulticastMessage *> MulticastMessageQueue;
NextViewBuffer(Dispatcher & dis);
NextViewBuffer(const NextViewBuffer & other);
virtual ~NextViewBuffer();
void initialise();
void finalise();
void pushReceiveMsg(const MulticastMessage & msg);
void pushSendMsg(MulticastMessage * msg);
void popReceiveMsgs(ViewID viewID);
void popSendMsgs();
bool isLockedSendMsgSemaphoreActivated();
void setLockedSendMsgSemaphore();
void unsetLockedSendMsgSemaphore();
void setLockedSendMsgSemaphoreAndStartFlush();
void unsetLockedSendMsgSemaphoreAndStopFlush();
NextViewBuffer & operator=(const NextViewBuffer & rhs);
bool isViewChangeAbleMessageType(const MoversightMessageType & msgType);
virtual void handleEvent(const ViewChangeEvent & e);
virtual void handleEvent(const JoinGroupDoneEvent & e );
private:
MulticastMessageQueue receivingMessageQueue;
MulticastMessageQueue sendingMessageQueue;
SubState lastState;
bool lockedSendMsgSemaphore;
};
}
}
#endif /* NEXTVIEWBUFFER_H */