Skip to content
Snippets Groups Projects
Commit 40af8667 authored by Ramin Yaghoubzadeh's avatar Ramin Yaghoubzadeh
Browse files

Added an ipaaca::Abort exception to throw instead of exit()

parent e44a5214
No related branches found
No related tags found
No related merge requests found
...@@ -156,6 +156,17 @@ class Exception: public std::exception//{{{ ...@@ -156,6 +156,17 @@ class Exception: public std::exception//{{{
return _description.c_str(); return _description.c_str();
} }
};//}}} };//}}}
class Abort: public std::exception//{{{
{
protected:
std::string _description;
public:
inline Abort(const std::string& description=""): _description(description) { }
inline ~Abort() throw() { }
const char* what() const throw() {
return _description.c_str();
}
};//}}}
/// a reentrant lock/mutex /// a reentrant lock/mutex
class Lock class Lock
......
...@@ -33,11 +33,12 @@ class ComponentNotifier { ...@@ -33,11 +33,12 @@ class ComponentNotifier {
public: public:
void add_notification_handler(ipaaca::IUEventHandlerFunction function); void add_notification_handler(ipaaca::IUEventHandlerFunction function);
void initialize(); void initialize();
void go_down();
protected: protected:
ipaaca::OutputBuffer::ptr out_buf; ipaaca::OutputBuffer::ptr out_buf;
ipaaca::InputBuffer::ptr in_buf; ipaaca::InputBuffer::ptr in_buf;
ipaaca::Lock lock; ipaaca::Lock lock;
bool initialized; bool initialized, gone_down;
std::vector<ipaaca::IUEventHandlerFunction> _handlers; std::vector<ipaaca::IUEventHandlerFunction> _handlers;
protected: protected:
std::string name; std::string name;
......
...@@ -5,13 +5,15 @@ namespace util { ...@@ -5,13 +5,15 @@ namespace util {
ComponentNotifier::~ComponentNotifier() ComponentNotifier::~ComponentNotifier()
{ {
LOG_IPAACA_CONSOLE("~ComponentNotifier")
if (initialized) { if (initialized) {
submit_notify(_IPAACA_COMP_NOTIF_STATE_DOWN); LOG_IPAACA_CONSOLE(" - notifying")
go_down();
} }
} }
ComponentNotifier::ComponentNotifier(const std::string& componentName, const std::string& componentFunction, const std::set<std::string>& sendCategories, const std::set<std::string>& recvCategories) ComponentNotifier::ComponentNotifier(const std::string& componentName, const std::string& componentFunction, const std::set<std::string>& sendCategories, const std::set<std::string>& recvCategories)
: initialized(false), name(componentName), function(componentFunction) : initialized(false), gone_down(false), name(componentName), function(componentFunction)
{ {
send_categories = ipaaca::str_join(sendCategories, ","); send_categories = ipaaca::str_join(sendCategories, ",");
recv_categories = ipaaca::str_join(recvCategories, ","); recv_categories = ipaaca::str_join(recvCategories, ",");
...@@ -85,5 +87,13 @@ void ComponentNotifier::initialize() { ...@@ -85,5 +87,13 @@ void ComponentNotifier::initialize() {
} }
} }
void ComponentNotifier::go_down() {
Locker locker(lock);
if (initialized && (!gone_down)) {
gone_down = true;
submit_notify(_IPAACA_COMP_NOTIF_STATE_DOWN);
}
}
}} }}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment