aboutsummaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h50
1 files changed, 6 insertions, 44 deletions
diff --git a/src/util.h b/src/util.h
index d5e8a71cd0..4fa5a08982 100644
--- a/src/util.h
+++ b/src/util.h
@@ -85,7 +85,6 @@ T* alignup(T* p)
#define strlwr(psz) to_lower(psz)
#define _strlwr(psz) to_lower(psz)
#define MAX_PATH 1024
-#define Beep(n1,n2) (0)
inline void Sleep(int64 n)
{
/*Boost has a year 2038 problem— if the request sleep time is past epoch+2^31 seconds the sleep returns instantly.
@@ -180,7 +179,7 @@ void AddTimeData(const CNetAddr& ip, int64 nTime);
-// Wrapper to automatically initialize mutex
+/** Wrapper to automatically initialize mutex. */
class CCriticalSection
{
protected:
@@ -193,7 +192,7 @@ public:
bool TryEnter(const char* pszName, const char* pszFile, int nLine);
};
-// Automatically leave critical section when leaving block, needed for exception safety
+/** RAII object that acquires mutex. Needed for exception safety. */
class CCriticalBlock
{
protected:
@@ -226,6 +225,7 @@ public:
#define LEAVE_CRITICAL_SECTION(cs) \
(cs).Leave()
+/** RAII object that tries to acquire mutex. Needed for exception safety. */
class CTryCriticalBlock
{
protected:
@@ -336,25 +336,6 @@ inline std::string HexStr(const std::vector<unsigned char>& vch, bool fSpaces=fa
}
template<typename T>
-std::string HexNumStr(const T itbegin, const T itend, bool f0x=true)
-{
- if (itbegin == itend)
- return "";
- const unsigned char* pbegin = (const unsigned char*)&itbegin[0];
- const unsigned char* pend = pbegin + (itend - itbegin) * sizeof(itbegin[0]);
- std::string str = (f0x ? "0x" : "");
- str.reserve(str.size() + (pend-pbegin) * 2);
- for (const unsigned char* p = pend-1; p >= pbegin; p--)
- str += strprintf("%02x", *p);
- return str;
-}
-
-inline std::string HexNumStr(const std::vector<unsigned char>& vch, bool f0x=true)
-{
- return HexNumStr(vch.begin(), vch.end(), f0x);
-}
-
-template<typename T>
void PrintHex(const T pbegin, const T pend, const char* pszFormat="%s", bool fSpaces=true)
{
printf(pszFormat, HexStr(pbegin, pend, fSpaces).c_str());
@@ -475,21 +456,6 @@ bool SoftSetBoolArg(const std::string& strArg, bool fValue);
} \
}
-#define CATCH_PRINT_EXCEPTION(pszFn) \
- catch (std::exception& e) { \
- PrintException(&e, (pszFn)); \
- } catch (...) { \
- PrintException(NULL, (pszFn)); \
- }
-
-
-
-
-
-
-
-
-
template<typename T1>
inline uint256 Hash(const T1 pbegin, const T1 pend)
@@ -558,8 +524,9 @@ inline uint160 Hash160(const std::vector<unsigned char>& vch)
}
-// Median filter over a stream of values
-// Returns the median of the last N numbers
+/** Median filter over a stream of values.
+ * Returns the median of the last N numbers
+ */
template <typename T> class CMedianFilter
{
private:
@@ -689,11 +656,6 @@ inline void SetThreadPriority(int nPriority)
#endif
}
-inline bool TerminateThread(pthread_t hthread, unsigned int nExitCode)
-{
- return (pthread_cancel(hthread) == 0);
-}
-
inline void ExitThread(size_t nExitCode)
{
pthread_exit((void*)nExitCode);