Commit 49b094cc authored by Martin Marinov's avatar Martin Marinov
Browse files

Add "aborting" flag to Node to handle cases where the PROGRESS_ABORTED...

Add "aborting" flag to Node to handle cases where the PROGRESS_ABORTED exception is thrown while IPOPT is being executed. Add some extra debugging to the Progress::TrackFunction.
parent badb563a
......@@ -9,7 +9,8 @@ namespace Progress {
typedef unsigned long long TickNumber;
class Node;
typedef void (*TrackFunction)(Node* _node);
typedef void (*TrackFunction)(Node* _node,
const char* const _flnm, const char* const _fnct);
extern thread_local TrackFunction trck_fnct;
......@@ -22,20 +23,27 @@ public:
Node(const char* const _name,
Node* _next = nullptr, Node* _chld = nullptr)
: name(_name), next_(_next), chld_(_chld),
tick_nmbr_max_(1000000000), abrt_(false)
void tick()
void tick(const char* const _flnm, const char* const _fnct)
if (trck_fnct != nullptr)
(*trck_fnct)(this, _flnm, _fnct);
TickNumber tick_number() const { return tick_nmbr_; }
TickNumber tick_number_max() const { return tick_nmbr_max_; }
double tick_percentage() const { return 100. * tick_nmbr_ / tick_nmbr_max_; }
// set this flag to indicate that the operation is being aborted
void set_aborting(const bool _abrt) { abrt_ = _abrt; }
// check if the the node is being aborted, this allows us to adjust exception
// handling
bool aborting() const { return abrt_; }
Node* next_; //!< next node on the same level, last if nullptr
Node* chld_; //!< first child node, leaf if nullptr
......@@ -43,6 +51,7 @@ protected:
TickNumber tick_nmbr_;
TickNumber tick_nmbr_max_;
bool abrt_;
extern thread_local Node* actv_node; // active node
......@@ -82,7 +91,14 @@ inline Node* make_children_list(MakeNodeFunction _make_node_fnct,
} //namespace Progress {
#define PROGRESS_TICK(NODE) { if ((NODE) != nullptr) (NODE)->tick(); }
#if defined(_MSC_VER)
#define __PROGRESS_FUNCTION__ __FUNCTION__ // works in VC well
#define __PROGRESS_FUNCTION__ __PRETTY_FUNCTION__ // needed for gcc & xcode
#endif// _MSC_VER
#define PROGRESS_TICK(NODE) { if ((NODE) != nullptr) \
(NODE)->tick(__FILE__, __PROGRESS_FUNCTION__); }
#define PROGRESS_ACTIVE_TICK PROGRESS_TICK(Progress::actv_node)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment