Changeset View
Changeset View
Standalone View
Standalone View
src/util.h
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | inline std::string _(const char *psz) { | ||||
boost::optional<std::string> rv = translationInterface.Translate(psz); | boost::optional<std::string> rv = translationInterface.Translate(psz); | ||||
return rv ? (*rv) : psz; | return rv ? (*rv) : psz; | ||||
} | } | ||||
void SetupEnvironment(); | void SetupEnvironment(); | ||||
bool SetupNetworking(); | bool SetupNetworking(); | ||||
template <typename... Args> bool error(const char *fmt, const Args &... args) { | template <typename... Args> bool error(const char *fmt, const Args &... args) { | ||||
LogPrintf("ERROR: " + tfm::format(fmt, args...) + "\n"); | LogPrint(BCLog::UTIL, "ERROR: " + tfm::format(fmt, args...) + "\n"); | ||||
return false; | return false; | ||||
} | } | ||||
void PrintExceptionContinue(const std::exception *pex, const char *pszThread); | void PrintExceptionContinue(const std::exception *pex, const char *pszThread); | ||||
void FileCommit(FILE *file); | void FileCommit(FILE *file); | ||||
bool TruncateFile(FILE *file, unsigned int length); | bool TruncateFile(FILE *file, unsigned int length); | ||||
int RaiseFileDescriptorLimit(int nMinFD); | int RaiseFileDescriptorLimit(int nMinFD); | ||||
void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length); | void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length); | ||||
▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* .. and a wrapper that just calls func once | * .. and a wrapper that just calls func once | ||||
*/ | */ | ||||
template <typename Callable> void TraceThread(const char *name, Callable func) { | template <typename Callable> void TraceThread(const char *name, Callable func) { | ||||
std::string s = strprintf("bitcoin-%s", name); | std::string s = strprintf("bitcoin-%s", name); | ||||
RenameThread(s.c_str()); | RenameThread(s.c_str()); | ||||
try { | try { | ||||
LogPrintf("%s thread start\n", name); | LogPrint(BCLog::UTIL, "%s thread start\n", name); | ||||
func(); | func(); | ||||
LogPrintf("%s thread exit\n", name); | LogPrint(BCLog::UTIL, "%s thread exit\n", name); | ||||
} catch (const boost::thread_interrupted &) { | } catch (const boost::thread_interrupted &) { | ||||
LogPrintf("%s thread interrupt\n", name); | LogPrint(BCLog::UTIL, "%s thread interrupt\n", name); | ||||
throw; | throw; | ||||
} catch (const std::exception &e) { | } catch (const std::exception &e) { | ||||
PrintExceptionContinue(&e, name); | PrintExceptionContinue(&e, name); | ||||
throw; | throw; | ||||
} catch (...) { | } catch (...) { | ||||
PrintExceptionContinue(nullptr, name); | PrintExceptionContinue(nullptr, name); | ||||
throw; | throw; | ||||
} | } | ||||
} | } | ||||
std::string CopyrightHolders(const std::string &strPrefix); | std::string CopyrightHolders(const std::string &strPrefix); | ||||
#endif // BITCOIN_UTIL_H | #endif // BITCOIN_UTIL_H |