/* #define DEBUGTRACE_ENABLED */ #include "lasp_indatahandler.h" #include "debugtrace.hpp" #include "lasp_streammgr.h" #include InDataHandler::InDataHandler(SmgrHandle mgr, const InCallbackType cb, const InResetType resetfcn) : _mgr(mgr), inCallback(cb), reset(resetfcn) #if LASP_DEBUG == 1 , main_thread_id(std::this_thread::get_id()) #endif { DEBUGTRACE_ENTER; #if LASP_DEBUG == 1 assert(mgr->main_thread_id == main_thread_id); #endif } void InDataHandler::start() { DEBUGTRACE_ENTER; checkRightThread(); if (SmgrHandle handle = _mgr.lock()) { handle->addInDataHandler(this); #if LASP_DEBUG == 1 assert(handle->main_thread_id == main_thread_id); #endif } } void InDataHandler::stop() { DEBUGTRACE_ENTER; checkRightThread(); #if LASP_DEBUG == 1 stopCalled = true; #endif if (SmgrHandle handle = _mgr.lock()) { handle->removeInDataHandler(*this); } } InDataHandler::~InDataHandler() { DEBUGTRACE_ENTER; checkRightThread(); #if LASP_DEBUG == 1 if (!stopCalled) { std::cerr << "************ BUG: Stop function not called while arriving at " "InDataHandler's destructor. Fix this by calling " "InDataHandler::stop()." << std::endl; abort(); } #endif } #if LASP_DEBUG == 1 void InDataHandler::checkRightThread() const { assert(std::this_thread::get_id() == main_thread_id); } #endif