diff --git a/Builds/VisualStudio2012/beast.vcxproj b/Builds/VisualStudio2012/beast.vcxproj
index 38133a41f..29b8ea374 100644
--- a/Builds/VisualStudio2012/beast.vcxproj
+++ b/Builds/VisualStudio2012/beast.vcxproj
@@ -154,10 +154,13 @@
+
+
+
@@ -329,9 +332,7 @@
-
-
@@ -511,6 +512,12 @@
true
true
+
+ true
+ true
+ true
+ true
+
true
true
diff --git a/Builds/VisualStudio2012/beast.vcxproj.filters b/Builds/VisualStudio2012/beast.vcxproj.filters
index b5ca3dc0e..2d991fef4 100644
--- a/Builds/VisualStudio2012/beast.vcxproj.filters
+++ b/Builds/VisualStudio2012/beast.vcxproj.filters
@@ -497,15 +497,9 @@
beast_core\threads
-
- beast_core\threads
-
beast_core\threads
-
- beast_core\threads
-
beast_core\threads
@@ -1239,6 +1233,15 @@
beast\thread
+
+ beast\thread
+
+
+ beast\thread
+
+
+ beast\thread
+
@@ -1790,6 +1793,9 @@
beast\thread\impl
+
+ beast\thread\impl
+
diff --git a/beast/Thread.h b/beast/Thread.h
index 208caed58..72e83d69f 100644
--- a/beast/Thread.h
+++ b/beast/Thread.h
@@ -26,6 +26,9 @@
#include "thread/SharedLockGuard.h"
#include "thread/SharedMutexAdapter.h"
#include "thread/SharedData.h"
+#include "thread/ServiceQueue.h"
+#include "thread/SpinLock.h"
+#include "thread/ThreadLocalValue.h"
#include "thread/WaitableEvent.h"
#endif
diff --git a/modules/beast_core/thread/ServiceQueue.h b/beast/thread/ServiceQueue.h
similarity index 98%
rename from modules/beast_core/thread/ServiceQueue.h
rename to beast/thread/ServiceQueue.h
index de921f0e4..1f5454051 100644
--- a/modules/beast_core/thread/ServiceQueue.h
+++ b/beast/thread/ServiceQueue.h
@@ -17,8 +17,14 @@
*/
//==============================================================================
-#ifndef BEAST_SERVICEQUEUE_H_INCLUDED
-#define BEAST_SERVICEQUEUE_H_INCLUDED
+#ifndef BEAST_THREAD_SERVICEQUEUE_H_INCLUDED
+#define BEAST_THREAD_SERVICEQUEUE_H_INCLUDED
+
+#include "../intrusive/List.h"
+#include "../intrusive/LockFreeStack.h"
+#include "SharedData.h"
+#include "ThreadLocalValue.h"
+#include "WaitableEvent.h"
namespace beast {
diff --git a/modules/beast_core/threads/SpinLock.h b/beast/thread/SpinLock.h
similarity index 82%
rename from modules/beast_core/threads/SpinLock.h
rename to beast/thread/SpinLock.h
index 87b9c2abd..37501659c 100644
--- a/modules/beast_core/threads/SpinLock.h
+++ b/beast/thread/SpinLock.h
@@ -21,8 +21,14 @@
*/
//==============================================================================
-#ifndef BEAST_SPINLOCK_H_INCLUDED
-#define BEAST_SPINLOCK_H_INCLUDED
+#ifndef BEAST_THREAD_SPINLOCK_H_INCLUDED
+#define BEAST_THREAD_SPINLOCK_H_INCLUDED
+
+#include "../Atomic.h"
+#include "LockGuard.h"
+#include "UnlockGuard.h"
+
+namespace beast {
//==============================================================================
/**
@@ -40,6 +46,12 @@
class BEAST_API SpinLock : public Uncopyable
{
public:
+ /** Provides the type of scoped lock to use for locking a SpinLock. */
+ typedef LockGuard ScopedLockType;
+
+ /** Provides the type of scoped unlocker to use with a SpinLock. */
+ typedef UnlockGuard ScopedUnlockType;
+
inline SpinLock() noexcept {}
inline ~SpinLock() noexcept {}
@@ -57,27 +69,29 @@ public:
/** Attempts to acquire the lock, returning true if this was successful. */
inline bool tryEnter() const noexcept
{
- return lock.compareAndSetBool (1, 0);
+ return m_lock.compareAndSetBool (1, 0);
}
/** Releases the lock. */
inline void exit() const noexcept
{
- bassert (lock.value == 1); // Agh! Releasing a lock that isn't currently held!
- lock = 0;
+ bassert (m_lock.value == 1); // Agh! Releasing a lock that isn't currently held!
+ m_lock = 0;
}
- //==============================================================================
- /** Provides the type of scoped lock to use for locking a SpinLock. */
- typedef GenericScopedLock ScopedLockType;
-
- /** Provides the type of scoped unlocker to use with a SpinLock. */
- typedef GenericScopedUnlock ScopedUnlockType;
+ void lock () const
+ { enter(); }
+ void unlock () const
+ { exit(); }
+ bool try_lock () const
+ { return tryEnter(); }
private:
//==============================================================================
- mutable Atomic lock;
+ mutable Atomic m_lock;
};
+}
+
+#endif
-#endif // BEAST_SPINLOCK_H_INCLUDED
diff --git a/beast/thread/Thread.cpp b/beast/thread/Thread.cpp
index d44ea8210..7bd7438ec 100644
--- a/beast/thread/Thread.cpp
+++ b/beast/thread/Thread.cpp
@@ -20,4 +20,5 @@
#include "BeastConfig.h"
#include "impl/RecursiveMutex.cpp"
+#include "impl/ServiceQueue.cpp"
#include "impl/WaitableEvent.cpp"
diff --git a/modules/beast_core/threads/ThreadLocalValue.h b/beast/thread/ThreadLocalValue.h
similarity index 97%
rename from modules/beast_core/threads/ThreadLocalValue.h
rename to beast/thread/ThreadLocalValue.h
index af623adbe..4b7e4908d 100644
--- a/modules/beast_core/threads/ThreadLocalValue.h
+++ b/beast/thread/ThreadLocalValue.h
@@ -21,8 +21,12 @@
*/
//==============================================================================
-#ifndef BEAST_THREADLOCALVALUE_H_INCLUDED
-#define BEAST_THREADLOCALVALUE_H_INCLUDED
+#ifndef BEAST_THREAD_THREADLOCALVALUE_H_INCLUDED
+#define BEAST_THREAD_THREADLOCALVALUE_H_INCLUDED
+
+#include "../Config.h"
+
+namespace beast {
// (NB: on win32, native thread-locals aren't possible in a dynamically loaded DLL in XP).
#if ! ((BEAST_MSVC && (BEAST_64BIT || ! defined (BeastPlugin_PluginCode))) \
@@ -186,5 +190,6 @@ private:
#endif
};
+}
-#endif // BEAST_THREADLOCALVALUE_H_INCLUDED
+#endif
diff --git a/beast/thread/impl/RecursiveMutex.cpp b/beast/thread/impl/RecursiveMutex.cpp
index 0fce37f4c..414f883c9 100644
--- a/beast/thread/impl/RecursiveMutex.cpp
+++ b/beast/thread/impl/RecursiveMutex.cpp
@@ -28,6 +28,11 @@
#include "../StaticAssert.h"
#include
+#undef check
+#undef direct
+#undef max
+#undef min
+#undef TYPE_BOOL
namespace beast {
diff --git a/modules/beast_core/thread/ServiceQueue.cpp b/beast/thread/impl/ServiceQueue.cpp
similarity index 99%
rename from modules/beast_core/thread/ServiceQueue.cpp
rename to beast/thread/impl/ServiceQueue.cpp
index e03b59071..ddf9bd4f0 100644
--- a/modules/beast_core/thread/ServiceQueue.cpp
+++ b/beast/thread/impl/ServiceQueue.cpp
@@ -17,6 +17,10 @@
*/
//==============================================================================
+#include "../ServiceQueue.h"
+
+#include "../../../modules/beast_core/beast_core.h" // for UnitTest
+
namespace beast {
namespace detail {
diff --git a/beast/thread/impl/WaitableEvent.cpp b/beast/thread/impl/WaitableEvent.cpp
index 0a976c783..9e882c499 100644
--- a/beast/thread/impl/WaitableEvent.cpp
+++ b/beast/thread/impl/WaitableEvent.cpp
@@ -26,6 +26,11 @@
#if BEAST_WINDOWS
#include
+#undef check
+#undef direct
+#undef max
+#undef min
+#undef TYPE_BOOL
namespace beast {
diff --git a/modules/beast_core/beast_core.cpp b/modules/beast_core/beast_core.cpp
index ba83844d7..da04f4dbe 100644
--- a/modules/beast_core/beast_core.cpp
+++ b/modules/beast_core/beast_core.cpp
@@ -274,8 +274,6 @@ namespace beast
}
-#include "thread/ServiceQueue.cpp"
-
// Has to be outside the beast namespace
extern "C" {
void beast_reportFatalError (char const* message, char const* fileName, int lineNumber)
diff --git a/modules/beast_core/beast_core.h b/modules/beast_core/beast_core.h
index 1ea063eb4..aa34fde6c 100644
--- a/modules/beast_core/beast_core.h
+++ b/modules/beast_core/beast_core.h
@@ -149,8 +149,6 @@ class FileOutputStream;
#include "memory/CacheLine.h"
#include "threads/ReadWriteMutex.h"
#include "threads/Thread.h"
-#include "threads/SpinLock.h"
-#include "threads/ThreadLocalValue.h"
#include "thread/MutexTraits.h"
#include "thread/TrackedMutex.h"
#include "diagnostic/FatalError.h"
@@ -245,8 +243,6 @@ class FileOutputStream;
}
-#include "thread/ServiceQueue.h"
-
#if BEAST_MSVC
#pragma warning (pop)
#endif