remove some comments
This commit is contained in:
		@@ -4,7 +4,6 @@
 | 
			
		||||
#include "xf/behavior.h"
 | 
			
		||||
#include "trace/trace.h"
 | 
			
		||||
 | 
			
		||||
// TODO done: Implement code for XFBehavior class
 | 
			
		||||
 | 
			
		||||
XFBehavior::XFBehavior() {
 | 
			
		||||
    this->deleteOnTerminate_ = false;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,5 @@
 | 
			
		||||
#include "xf/customevent.h"
 | 
			
		||||
 | 
			
		||||
// TODO done: Implement code for XFCustomEvent class
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
XFCustomEvent::XFCustomEvent(int id, interface::XFBehavior *pBehavior):
 | 
			
		||||
    XFEvent(XFEventType::Event, id){
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,5 @@
 | 
			
		||||
#include "xf/defaulttransition.h"
 | 
			
		||||
 | 
			
		||||
// TODO done: Implement code for XFDefaultTransition class
 | 
			
		||||
 | 
			
		||||
XFDefaultTransition::XFDefaultTransition():
 | 
			
		||||
    XFEvent(XFEventType::DefaultTransition) {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,5 @@
 | 
			
		||||
#include "xf/initialevent.h"
 | 
			
		||||
 | 
			
		||||
// TODO done: Implement code for XFInitialEvent class
 | 
			
		||||
 | 
			
		||||
XFInitialEvent::XFInitialEvent():
 | 
			
		||||
    XFEvent(XFEventType::Initial) {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,7 @@
 | 
			
		||||
#include "xf/timeout.h"
 | 
			
		||||
 | 
			
		||||
// TODO done: Implement code for XFTimeout class
 | 
			
		||||
 | 
			
		||||
XFTimeout::XFTimeout(int id, int interval, interface::XFBehavior *pBehavior):
 | 
			
		||||
    XFEvent(XFEventType::Timeout, id), interval_(interval) {
 | 
			
		||||
    this->setRelTicks(this->getInterval());
 | 
			
		||||
    setBehavior(pBehavior);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,8 +24,6 @@ interface::XFDispatcher * interface::XFDispatcher::getInstance() {
 | 
			
		||||
    return &dispatcher;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TODO done: Implement code for XFDispatcher class
 | 
			
		||||
 | 
			
		||||
XFDispatcher::XFDispatcher() {
 | 
			
		||||
    this->pMutex_ = interface::XFMutex::create();
 | 
			
		||||
}
 | 
			
		||||
@@ -35,7 +33,6 @@ XFDispatcher::~XFDispatcher() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void XFDispatcher::dispatchEvent(const XFEvent *pEvent) const {
 | 
			
		||||
    //Trace::out("[DEBUG] - Dispatch Event");
 | 
			
		||||
    XFBehavior::TerminateBehavior terminateBehavior;
 | 
			
		||||
    terminateBehavior = pEvent->getBehavior()->process(pEvent);
 | 
			
		||||
    if(terminateBehavior && pEvent->getBehavior()->deleteOnTerminate()) {
 | 
			
		||||
@@ -47,7 +44,6 @@ void XFDispatcher::dispatchEvent(const XFEvent *pEvent) const {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void XFDispatcher::pushEvent(XFEvent *pEvent) {
 | 
			
		||||
    //Trace::out("[DEBUG] - Push Event");
 | 
			
		||||
    this->pMutex_->lock();
 | 
			
		||||
    events_.push(pEvent, false);
 | 
			
		||||
    this->pMutex_->unlock();
 | 
			
		||||
 
 | 
			
		||||
@@ -24,8 +24,6 @@ interface::XFTimeoutManager * interface::XFTimeoutManager::getInstance() {
 | 
			
		||||
    return &timeoutManager;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TODO done: Implement code for XFTimeoutManager class
 | 
			
		||||
 | 
			
		||||
XFTimeoutManager::XFTimeoutManager() {
 | 
			
		||||
    this->pMutex_ = interface::XFMutex::create();
 | 
			
		||||
}
 | 
			
		||||
@@ -35,6 +33,17 @@ XFTimeoutManager::~XFTimeoutManager() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void XFTimeoutManager::addTimeout(XFTimeout *pNewTimeout) {
 | 
			
		||||
 | 
			
		||||
    const int desireInterval = pNewTimeout->getInterval();
 | 
			
		||||
 | 
			
		||||
    TimeoutList::iterator it;
 | 
			
		||||
    do {
 | 
			
		||||
        // TODO, super algorithm
 | 
			
		||||
    } while (true);
 | 
			
		||||
 | 
			
		||||
    int ticks = pNewTimeout->getInterval() / this->tickInterval_;
 | 
			
		||||
    pNewTimeout->setRelTicks(ticks);
 | 
			
		||||
 | 
			
		||||
    this->pMutex_->lock();
 | 
			
		||||
    this->timeouts_.push_back(pNewTimeout);
 | 
			
		||||
    this->pMutex_->unlock();
 | 
			
		||||
@@ -53,17 +62,11 @@ void XFTimeoutManager::start(std::function<void (uint32_t)> startTimeoutManagerT
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void XFTimeoutManager::scheduleTimeout(int32_t timeoutId, int32_t interval, interface::XFBehavior *pBehavior) {
 | 
			
		||||
    string str = "[DEBUG] - Schedule Timeout: ";
 | 
			
		||||
    str += to_string(timeoutId);
 | 
			
		||||
    //Trace::out(str);
 | 
			
		||||
    ::XFTimeout* timeout = new XFTimeout(timeoutId, interval, pBehavior);
 | 
			
		||||
    addTimeout(timeout);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void XFTimeoutManager::unscheduleTimeout(int32_t timeoutId, interface::XFBehavior *pBehavior) {
 | 
			
		||||
    string str = "[DEBUG] - Unschedule Timeout: ";
 | 
			
		||||
    str += to_string(timeoutId);
 | 
			
		||||
    //Trace::out(str);
 | 
			
		||||
    this->pMutex_->lock();
 | 
			
		||||
    TimeoutList::iterator it;
 | 
			
		||||
    for(it = this->timeouts_.begin(); it != this->timeouts_.end(); it++){
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user