forked from taskflow/taskflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.hpp
More file actions
73 lines (53 loc) · 2 KB
/
Copy patherror.hpp
File metadata and controls
73 lines (53 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once
#include <iostream>
#include <sstream>
#include <exception>
#include "../utility/stream.hpp"
namespace tf {
// node-specific states
struct NSTATE {
using underlying_type = int;
constexpr static underlying_type NONE = 0x00000000;
constexpr static underlying_type CONDITIONED = 0x10000000;
constexpr static underlying_type PREEMPTED = 0x20000000;
constexpr static underlying_type RETAIN_ON_JOIN = 0x40000000;
constexpr static underlying_type JOINED = 0x80000000;
// mask to isolate state bits - non-state bits store # weak dependents
constexpr static underlying_type MASK = 0xF0000000;
};
using nstate_t = NSTATE::underlying_type;
// exception-specific states
struct ESTATE {
using underlying_type = int;
constexpr static underlying_type NONE = 0x00000000;
constexpr static underlying_type EXCEPTION = 0x10000000;
constexpr static underlying_type CANCELLED = 0x20000000;
constexpr static underlying_type ANCHORED = 0x40000000;
};
using estate_t = ESTATE::underlying_type;
// async-specific states
struct ASTATE {
using underlying_type = int;
constexpr static underlying_type UNFINISHED = 0;
constexpr static underlying_type LOCKED = 1;
constexpr static underlying_type FINISHED = 2;
};
using astate_t = ASTATE::underlying_type;
// Procedure: throw_re
// Throws runtime error under a given error code.
template <typename... ArgsT>
//void throw_se(const char* fname, const size_t line, Error::Code c, ArgsT&&... args) {
void throw_re(const char* fname, const size_t line, ArgsT&&... args) {
std::ostringstream oss;
oss << "[" << fname << ":" << line << "] ";
//ostreamize(oss, std::forward<ArgsT>(args)...);
(oss << ... << args);
#ifdef TF_DISABLE_EXCEPTION_HANDLING
std::cerr << oss.str();
std::terminate();
#else
throw std::runtime_error(oss.str());
#endif
}
} // ------------------------------------------------------------------------
#define TF_THROW(...) tf::throw_re(__FILE__, __LINE__, __VA_ARGS__);