aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-08-20 17:43:56 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-08-26 13:25:21 +0200
commit610a8c075958aa95b97f62a7ab020a543694c23d (patch)
tree8639401fd1aeeac4314c44552d4473c1f8652109 /src
parentf780e65ac632d2cad51d00c2b4a93248a5df91a6 (diff)
Move SetThreadPriority implementation to util.cpp instead of the header
Put the THREAD_* and PRIO_ constants in compat.h.
Diffstat (limited to 'src')
-rw-r--r--src/compat.h11
-rw-r--r--src/util.cpp13
-rw-r--r--src/util.h29
3 files changed, 25 insertions, 28 deletions
diff --git a/src/compat.h b/src/compat.h
index 52c7817130..3f0a8b6158 100644
--- a/src/compat.h
+++ b/src/compat.h
@@ -59,4 +59,15 @@ typedef u_int SOCKET;
#define SOCKET_ERROR -1
#endif
+#ifndef WIN32
+// PRIO_MAX is not defined on Solaris
+#ifndef PRIO_MAX
+#define PRIO_MAX 20
+#endif
+#define THREAD_PRIORITY_LOWEST PRIO_MAX
+#define THREAD_PRIORITY_BELOW_NORMAL 2
+#define THREAD_PRIORITY_NORMAL 0
+#define THREAD_PRIORITY_ABOVE_NORMAL (-2)
+#endif
+
#endif // _BITCOIN_COMPAT_H
diff --git a/src/util.cpp b/src/util.cpp
index ae2145a3a0..606f5a60f9 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -1286,3 +1286,16 @@ std::string FormatParagraph(const std::string in, size_t width, size_t indent)
}
return out.str();
}
+
+void SetThreadPriority(int nPriority)
+{
+#ifdef WIN32
+ SetThreadPriority(GetCurrentThread(), nPriority);
+#else // WIN32
+#ifdef PRIO_THREAD
+ setpriority(PRIO_THREAD, 0, nPriority);
+#else // PRIO_THREAD
+ setpriority(PRIO_PROCESS, 0, nPriority);
+#endif // PRIO_THREAD
+#endif // WIN32
+}
diff --git a/src/util.h b/src/util.h
index 785d4056e7..939e59c301 100644
--- a/src/util.h
+++ b/src/util.h
@@ -342,34 +342,7 @@ bool TimingResistantEqual(const T& a, const T& b)
return accumulator == 0;
}
-#ifdef WIN32
-inline void SetThreadPriority(int nPriority)
-{
- SetThreadPriority(GetCurrentThread(), nPriority);
-}
-#else
-
-// PRIO_MAX is not defined on Solaris
-#ifndef PRIO_MAX
-#define PRIO_MAX 20
-#endif
-#define THREAD_PRIORITY_LOWEST PRIO_MAX
-#define THREAD_PRIORITY_BELOW_NORMAL 2
-#define THREAD_PRIORITY_NORMAL 0
-#define THREAD_PRIORITY_ABOVE_NORMAL (-2)
-
-inline void SetThreadPriority(int nPriority)
-{
- // It's unclear if it's even possible to change thread priorities on Linux,
- // but we really and truly need it for the generation threads.
-#ifdef PRIO_THREAD
- setpriority(PRIO_THREAD, 0, nPriority);
-#else
- setpriority(PRIO_PROCESS, 0, nPriority);
-#endif
-}
-#endif
-
+void SetThreadPriority(int nPriority);
void RenameThread(const char* name);
// Standard wrapper for do-something-forever thread functions.