mirror of https://github.com/Icinga/icinga2.git
Move inline functions to their .cpp files
This commit is contained in:
parent
91c256261a
commit
f05459b40c
|
@ -406,3 +406,34 @@ Dictionary::Ptr ValidationError::GetDebugHint() const
|
|||
return m_DebugHint;
|
||||
}
|
||||
|
||||
std::string icinga::to_string(const StackTraceErrorInfo&)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
std::string icinga::to_string(const errinfo_win32_error& e)
|
||||
{
|
||||
return "[errinfo_win32_error] = " + Utility::FormatErrorNumber(e.value()) + "\n";
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
std::string icinga::to_string(const errinfo_getaddrinfo_error& e)
|
||||
{
|
||||
String msg;
|
||||
|
||||
#ifdef _WIN32
|
||||
msg = gai_strerrorA(e.value());
|
||||
#else /* _WIN32 */
|
||||
msg = gai_strerror(e.value());
|
||||
#endif /* _WIN32 */
|
||||
|
||||
return "[errinfo_getaddrinfo_error] = " + String(msg) + "\n";
|
||||
}
|
||||
|
||||
std::string icinga::to_string(const ContextTraceErrorInfo& e)
|
||||
{
|
||||
std::ostringstream msgbuf;
|
||||
msgbuf << "[Context] = " << e.value();
|
||||
return msgbuf.str();
|
||||
}
|
||||
|
|
|
@ -106,19 +106,11 @@ void RethrowUncaughtException();
|
|||
|
||||
typedef boost::error_info<StackTrace, StackTrace> StackTraceErrorInfo;
|
||||
|
||||
inline std::string to_string(const StackTraceErrorInfo&)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
std::string to_string(const StackTraceErrorInfo&);
|
||||
|
||||
typedef boost::error_info<ContextTrace, ContextTrace> ContextTraceErrorInfo;
|
||||
|
||||
inline std::string to_string(const ContextTraceErrorInfo& e)
|
||||
{
|
||||
std::ostringstream msgbuf;
|
||||
msgbuf << "[Context] = " << e.value();
|
||||
return msgbuf.str();
|
||||
}
|
||||
std::string to_string(const ContextTraceErrorInfo& e);
|
||||
|
||||
String DiagnosticInformation(const std::exception& ex, bool verbose = true, StackTrace *stack = nullptr, ContextTrace *context = nullptr);
|
||||
String DiagnosticInformation(const boost::exception_ptr& eptr, bool verbose = true);
|
||||
|
@ -139,27 +131,13 @@ class win32_error : virtual public std::exception, virtual public boost::excepti
|
|||
struct errinfo_win32_error_;
|
||||
typedef boost::error_info<struct errinfo_win32_error_, int> errinfo_win32_error;
|
||||
|
||||
inline std::string to_string(const errinfo_win32_error& e)
|
||||
{
|
||||
return "[errinfo_win32_error] = " + Utility::FormatErrorNumber(e.value()) + "\n";
|
||||
}
|
||||
std::string to_string(const errinfo_win32_error& e);
|
||||
#endif /* _WIN32 */
|
||||
|
||||
struct errinfo_getaddrinfo_error_;
|
||||
typedef boost::error_info<struct errinfo_getaddrinfo_error_, int> errinfo_getaddrinfo_error;
|
||||
|
||||
inline std::string to_string(const errinfo_getaddrinfo_error& e)
|
||||
{
|
||||
String msg;
|
||||
|
||||
#ifdef _WIN32
|
||||
msg = gai_strerrorA(e.value());
|
||||
#else /* _WIN32 */
|
||||
msg = gai_strerror(e.value());
|
||||
#endif /* _WIN32 */
|
||||
|
||||
return "[errinfo_getaddrinfo_error] = " + String(msg) + "\n";
|
||||
}
|
||||
std::string to_string(const errinfo_getaddrinfo_error& e);
|
||||
|
||||
struct errinfo_message_;
|
||||
typedef boost::error_info<struct errinfo_message_, std::string> errinfo_message;
|
||||
|
|
|
@ -252,3 +252,35 @@ INITIALIZE_ONCE([]() {
|
|||
});
|
||||
#endif /* I2_LEAK_DEBUG */
|
||||
|
||||
void icinga::intrusive_ptr_add_ref(Object *object)
|
||||
{
|
||||
#ifdef I2_LEAK_DEBUG
|
||||
if (object->m_References == 0)
|
||||
TypeAddObject(object);
|
||||
#endif /* I2_LEAK_DEBUG */
|
||||
|
||||
#ifdef _WIN32
|
||||
InterlockedIncrement(&object->m_References);
|
||||
#else /* _WIN32 */
|
||||
__sync_add_and_fetch(&object->m_References, 1);
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
void icinga::intrusive_ptr_release(Object *object)
|
||||
{
|
||||
uintptr_t refs;
|
||||
|
||||
#ifdef _WIN32
|
||||
refs = InterlockedDecrement(&object->m_References);
|
||||
#else /* _WIN32 */
|
||||
refs = __sync_sub_and_fetch(&object->m_References, 1);
|
||||
#endif /* _WIN32 */
|
||||
|
||||
if (unlikely(refs == 0)) {
|
||||
#ifdef I2_LEAK_DEBUG
|
||||
TypeRemoveObject(object);
|
||||
#endif /* I2_LEAK_DEBUG */
|
||||
|
||||
delete object;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,38 +164,8 @@ Value GetPrototypeField(const Value& context, const String& field, bool not_foun
|
|||
void TypeAddObject(Object *object);
|
||||
void TypeRemoveObject(Object *object);
|
||||
|
||||
inline void intrusive_ptr_add_ref(Object *object)
|
||||
{
|
||||
#ifdef I2_LEAK_DEBUG
|
||||
if (object->m_References == 0)
|
||||
TypeAddObject(object);
|
||||
#endif /* I2_LEAK_DEBUG */
|
||||
|
||||
#ifdef _WIN32
|
||||
InterlockedIncrement(&object->m_References);
|
||||
#else /* _WIN32 */
|
||||
__sync_add_and_fetch(&object->m_References, 1);
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
inline void intrusive_ptr_release(Object *object)
|
||||
{
|
||||
uintptr_t refs;
|
||||
|
||||
#ifdef _WIN32
|
||||
refs = InterlockedDecrement(&object->m_References);
|
||||
#else /* _WIN32 */
|
||||
refs = __sync_sub_and_fetch(&object->m_References, 1);
|
||||
#endif /* _WIN32 */
|
||||
|
||||
if (unlikely(refs == 0)) {
|
||||
#ifdef I2_LEAK_DEBUG
|
||||
TypeRemoveObject(object);
|
||||
#endif /* I2_LEAK_DEBUG */
|
||||
|
||||
delete object;
|
||||
}
|
||||
}
|
||||
void intrusive_ptr_add_ref(Object *object);
|
||||
void intrusive_ptr_release(Object *object);
|
||||
|
||||
template<typename T>
|
||||
class ObjectImpl
|
||||
|
|
|
@ -782,4 +782,19 @@ bool VerifyCertificate(const std::shared_ptr<X509>& caCertificate, const std::sh
|
|||
return rc == 1;
|
||||
}
|
||||
|
||||
std::string to_string(const errinfo_openssl_error& e)
|
||||
{
|
||||
std::ostringstream tmp;
|
||||
int code = e.value();
|
||||
char errbuf[120];
|
||||
|
||||
const char *message = ERR_error_string(code, errbuf);
|
||||
|
||||
if (!message)
|
||||
message = "Unknown error.";
|
||||
|
||||
tmp << code << ", \"" << message << "\"";
|
||||
return "[errinfo_openssl_error]" + tmp.str() + "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,20 +61,7 @@ class openssl_error : virtual public std::exception, virtual public boost::excep
|
|||
struct errinfo_openssl_error_;
|
||||
typedef boost::error_info<struct errinfo_openssl_error_, unsigned long> errinfo_openssl_error;
|
||||
|
||||
inline std::string to_string(const errinfo_openssl_error& e)
|
||||
{
|
||||
std::ostringstream tmp;
|
||||
int code = e.value();
|
||||
char errbuf[120];
|
||||
|
||||
const char *message = ERR_error_string(code, errbuf);
|
||||
|
||||
if (!message)
|
||||
message = "Unknown error.";
|
||||
|
||||
tmp << code << ", \"" << message << "\"";
|
||||
return "[errinfo_openssl_error]" + tmp.str() + "\n";
|
||||
}
|
||||
std::string to_string(const errinfo_openssl_error& e);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -299,3 +299,18 @@ size_t WorkQueue::GetTaskCount(RingBuffer::SizeType span)
|
|||
boost::mutex::scoped_lock lock(m_StatsMutex);
|
||||
return m_TaskStats.UpdateAndGetValues(Utility::GetTime(), span);
|
||||
}
|
||||
|
||||
bool icinga::operator<(const Task& a, const Task& b)
|
||||
{
|
||||
if (a.Priority < b.Priority)
|
||||
return true;
|
||||
|
||||
if (a.Priority == b.Priority) {
|
||||
if (a.ID > b.ID)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -54,20 +54,7 @@ struct Task
|
|||
int ID{-1};
|
||||
};
|
||||
|
||||
inline bool operator<(const Task& a, const Task& b)
|
||||
{
|
||||
if (a.Priority < b.Priority)
|
||||
return true;
|
||||
|
||||
if (a.Priority == b.Priority) {
|
||||
if (a.ID > b.ID)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
bool operator<(const Task& a, const Task& b);
|
||||
|
||||
/**
|
||||
* A workqueue.
|
||||
|
|
Loading…
Reference in New Issue