mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
Move ServiceQueue, ThreadLocalValue, SpinLock
This commit is contained in:
@@ -154,10 +154,13 @@
|
|||||||
<ClInclude Include="..\..\beast\Thread.h" />
|
<ClInclude Include="..\..\beast\Thread.h" />
|
||||||
<ClInclude Include="..\..\beast\thread\LockGuard.h" />
|
<ClInclude Include="..\..\beast\thread\LockGuard.h" />
|
||||||
<ClInclude Include="..\..\beast\thread\RecursiveMutex.h" />
|
<ClInclude Include="..\..\beast\thread\RecursiveMutex.h" />
|
||||||
|
<ClInclude Include="..\..\beast\thread\ServiceQueue.h" />
|
||||||
<ClInclude Include="..\..\beast\thread\SharedData.h" />
|
<ClInclude Include="..\..\beast\thread\SharedData.h" />
|
||||||
<ClInclude Include="..\..\beast\thread\SharedLockGuard.h" />
|
<ClInclude Include="..\..\beast\thread\SharedLockGuard.h" />
|
||||||
<ClInclude Include="..\..\beast\thread\SharedMutexAdapter.h" />
|
<ClInclude Include="..\..\beast\thread\SharedMutexAdapter.h" />
|
||||||
<ClInclude Include="..\..\beast\Chrono.h" />
|
<ClInclude Include="..\..\beast\Chrono.h" />
|
||||||
|
<ClInclude Include="..\..\beast\thread\SpinLock.h" />
|
||||||
|
<ClInclude Include="..\..\beast\thread\ThreadLocalValue.h" />
|
||||||
<ClInclude Include="..\..\beast\thread\TryLockGuard.h" />
|
<ClInclude Include="..\..\beast\thread\TryLockGuard.h" />
|
||||||
<ClInclude Include="..\..\beast\thread\UnlockGuard.h" />
|
<ClInclude Include="..\..\beast\thread\UnlockGuard.h" />
|
||||||
<ClInclude Include="..\..\beast\thread\WaitableEvent.h" />
|
<ClInclude Include="..\..\beast\thread\WaitableEvent.h" />
|
||||||
@@ -329,9 +332,7 @@
|
|||||||
<ClInclude Include="..\..\modules\beast_core\threads\ScopedReadLock.h" />
|
<ClInclude Include="..\..\modules\beast_core\threads\ScopedReadLock.h" />
|
||||||
<ClInclude Include="..\..\modules\beast_core\threads\ScopedWriteLock.h" />
|
<ClInclude Include="..\..\modules\beast_core\threads\ScopedWriteLock.h" />
|
||||||
<ClInclude Include="..\..\modules\beast_core\threads\SpinDelay.h" />
|
<ClInclude Include="..\..\modules\beast_core\threads\SpinDelay.h" />
|
||||||
<ClInclude Include="..\..\modules\beast_core\threads\SpinLock.h" />
|
|
||||||
<ClInclude Include="..\..\modules\beast_core\threads\Thread.h" />
|
<ClInclude Include="..\..\modules\beast_core\threads\Thread.h" />
|
||||||
<ClInclude Include="..\..\modules\beast_core\threads\ThreadLocalValue.h" />
|
|
||||||
<ClInclude Include="..\..\modules\beast_core\threads\ThreadPool.h" />
|
<ClInclude Include="..\..\modules\beast_core\threads\ThreadPool.h" />
|
||||||
<ClInclude Include="..\..\modules\beast_core\threads\TimeSliceThread.h" />
|
<ClInclude Include="..\..\modules\beast_core\threads\TimeSliceThread.h" />
|
||||||
<ClInclude Include="..\..\modules\beast_core\thread\DeadlineTimer.h" />
|
<ClInclude Include="..\..\modules\beast_core\thread\DeadlineTimer.h" />
|
||||||
@@ -511,6 +512,12 @@
|
|||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\beast\thread\impl\ServiceQueue.cpp">
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\beast\thread\impl\WaitableEvent.cpp">
|
<ClCompile Include="..\..\beast\thread\impl\WaitableEvent.cpp">
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||||
|
|||||||
@@ -497,15 +497,9 @@
|
|||||||
<ClInclude Include="..\..\modules\beast_core\threads\ScopedWriteLock.h">
|
<ClInclude Include="..\..\modules\beast_core\threads\ScopedWriteLock.h">
|
||||||
<Filter>beast_core\threads</Filter>
|
<Filter>beast_core\threads</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\modules\beast_core\threads\SpinLock.h">
|
|
||||||
<Filter>beast_core\threads</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\modules\beast_core\threads\Thread.h">
|
<ClInclude Include="..\..\modules\beast_core\threads\Thread.h">
|
||||||
<Filter>beast_core\threads</Filter>
|
<Filter>beast_core\threads</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\modules\beast_core\threads\ThreadLocalValue.h">
|
|
||||||
<Filter>beast_core\threads</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\modules\beast_core\threads\ThreadPool.h">
|
<ClInclude Include="..\..\modules\beast_core\threads\ThreadPool.h">
|
||||||
<Filter>beast_core\threads</Filter>
|
<Filter>beast_core\threads</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -1239,6 +1233,15 @@
|
|||||||
<ClInclude Include="..\..\beast\thread\WaitableEvent.h">
|
<ClInclude Include="..\..\beast\thread\WaitableEvent.h">
|
||||||
<Filter>beast\thread</Filter>
|
<Filter>beast\thread</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\beast\thread\ServiceQueue.h">
|
||||||
|
<Filter>beast\thread</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\beast\thread\ThreadLocalValue.h">
|
||||||
|
<Filter>beast\thread</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\beast\thread\SpinLock.h">
|
||||||
|
<Filter>beast\thread</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\modules\beast_core\containers\AbstractFifo.cpp">
|
<ClCompile Include="..\..\modules\beast_core\containers\AbstractFifo.cpp">
|
||||||
@@ -1790,6 +1793,9 @@
|
|||||||
<ClCompile Include="..\..\beast\thread\impl\WaitableEvent.cpp">
|
<ClCompile Include="..\..\beast\thread\impl\WaitableEvent.cpp">
|
||||||
<Filter>beast\thread\impl</Filter>
|
<Filter>beast\thread\impl</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\beast\thread\impl\ServiceQueue.cpp">
|
||||||
|
<Filter>beast\thread\impl</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Text Include="..\..\TODO.txt">
|
<Text Include="..\..\TODO.txt">
|
||||||
|
|||||||
@@ -26,6 +26,9 @@
|
|||||||
#include "thread/SharedLockGuard.h"
|
#include "thread/SharedLockGuard.h"
|
||||||
#include "thread/SharedMutexAdapter.h"
|
#include "thread/SharedMutexAdapter.h"
|
||||||
#include "thread/SharedData.h"
|
#include "thread/SharedData.h"
|
||||||
|
#include "thread/ServiceQueue.h"
|
||||||
|
#include "thread/SpinLock.h"
|
||||||
|
#include "thread/ThreadLocalValue.h"
|
||||||
#include "thread/WaitableEvent.h"
|
#include "thread/WaitableEvent.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,8 +17,14 @@
|
|||||||
*/
|
*/
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#ifndef BEAST_SERVICEQUEUE_H_INCLUDED
|
#ifndef BEAST_THREAD_SERVICEQUEUE_H_INCLUDED
|
||||||
#define BEAST_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 {
|
namespace beast {
|
||||||
|
|
||||||
@@ -21,8 +21,14 @@
|
|||||||
*/
|
*/
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#ifndef BEAST_SPINLOCK_H_INCLUDED
|
#ifndef BEAST_THREAD_SPINLOCK_H_INCLUDED
|
||||||
#define BEAST_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
|
class BEAST_API SpinLock : public Uncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/** Provides the type of scoped lock to use for locking a SpinLock. */
|
||||||
|
typedef LockGuard <SpinLock> ScopedLockType;
|
||||||
|
|
||||||
|
/** Provides the type of scoped unlocker to use with a SpinLock. */
|
||||||
|
typedef UnlockGuard <SpinLock> ScopedUnlockType;
|
||||||
|
|
||||||
inline SpinLock() noexcept {}
|
inline SpinLock() noexcept {}
|
||||||
inline ~SpinLock() noexcept {}
|
inline ~SpinLock() noexcept {}
|
||||||
|
|
||||||
@@ -57,27 +69,29 @@ public:
|
|||||||
/** Attempts to acquire the lock, returning true if this was successful. */
|
/** Attempts to acquire the lock, returning true if this was successful. */
|
||||||
inline bool tryEnter() const noexcept
|
inline bool tryEnter() const noexcept
|
||||||
{
|
{
|
||||||
return lock.compareAndSetBool (1, 0);
|
return m_lock.compareAndSetBool (1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Releases the lock. */
|
/** Releases the lock. */
|
||||||
inline void exit() const noexcept
|
inline void exit() const noexcept
|
||||||
{
|
{
|
||||||
bassert (lock.value == 1); // Agh! Releasing a lock that isn't currently held!
|
bassert (m_lock.value == 1); // Agh! Releasing a lock that isn't currently held!
|
||||||
lock = 0;
|
m_lock = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
void lock () const
|
||||||
/** Provides the type of scoped lock to use for locking a SpinLock. */
|
{ enter(); }
|
||||||
typedef GenericScopedLock <SpinLock> ScopedLockType;
|
void unlock () const
|
||||||
|
{ exit(); }
|
||||||
/** Provides the type of scoped unlocker to use with a SpinLock. */
|
bool try_lock () const
|
||||||
typedef GenericScopedUnlock <SpinLock> ScopedUnlockType;
|
{ return tryEnter(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
mutable Atomic<int> lock;
|
mutable Atomic<int> m_lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // BEAST_SPINLOCK_H_INCLUDED
|
|
||||||
@@ -20,4 +20,5 @@
|
|||||||
#include "BeastConfig.h"
|
#include "BeastConfig.h"
|
||||||
|
|
||||||
#include "impl/RecursiveMutex.cpp"
|
#include "impl/RecursiveMutex.cpp"
|
||||||
|
#include "impl/ServiceQueue.cpp"
|
||||||
#include "impl/WaitableEvent.cpp"
|
#include "impl/WaitableEvent.cpp"
|
||||||
|
|||||||
@@ -21,8 +21,12 @@
|
|||||||
*/
|
*/
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#ifndef BEAST_THREADLOCALVALUE_H_INCLUDED
|
#ifndef BEAST_THREAD_THREADLOCALVALUE_H_INCLUDED
|
||||||
#define BEAST_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).
|
// (NB: on win32, native thread-locals aren't possible in a dynamically loaded DLL in XP).
|
||||||
#if ! ((BEAST_MSVC && (BEAST_64BIT || ! defined (BeastPlugin_PluginCode))) \
|
#if ! ((BEAST_MSVC && (BEAST_64BIT || ! defined (BeastPlugin_PluginCode))) \
|
||||||
@@ -186,5 +190,6 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // BEAST_THREADLOCALVALUE_H_INCLUDED
|
#endif
|
||||||
@@ -28,6 +28,11 @@
|
|||||||
#include "../StaticAssert.h"
|
#include "../StaticAssert.h"
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
#undef check
|
||||||
|
#undef direct
|
||||||
|
#undef max
|
||||||
|
#undef min
|
||||||
|
#undef TYPE_BOOL
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
|
#include "../ServiceQueue.h"
|
||||||
|
|
||||||
|
#include "../../../modules/beast_core/beast_core.h" // for UnitTest
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
@@ -26,6 +26,11 @@
|
|||||||
#if BEAST_WINDOWS
|
#if BEAST_WINDOWS
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
#undef check
|
||||||
|
#undef direct
|
||||||
|
#undef max
|
||||||
|
#undef min
|
||||||
|
#undef TYPE_BOOL
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
|
|||||||
@@ -274,8 +274,6 @@ namespace beast
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "thread/ServiceQueue.cpp"
|
|
||||||
|
|
||||||
// Has to be outside the beast namespace
|
// Has to be outside the beast namespace
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void beast_reportFatalError (char const* message, char const* fileName, int lineNumber)
|
void beast_reportFatalError (char const* message, char const* fileName, int lineNumber)
|
||||||
|
|||||||
@@ -149,8 +149,6 @@ class FileOutputStream;
|
|||||||
#include "memory/CacheLine.h"
|
#include "memory/CacheLine.h"
|
||||||
#include "threads/ReadWriteMutex.h"
|
#include "threads/ReadWriteMutex.h"
|
||||||
#include "threads/Thread.h"
|
#include "threads/Thread.h"
|
||||||
#include "threads/SpinLock.h"
|
|
||||||
#include "threads/ThreadLocalValue.h"
|
|
||||||
#include "thread/MutexTraits.h"
|
#include "thread/MutexTraits.h"
|
||||||
#include "thread/TrackedMutex.h"
|
#include "thread/TrackedMutex.h"
|
||||||
#include "diagnostic/FatalError.h"
|
#include "diagnostic/FatalError.h"
|
||||||
@@ -245,8 +243,6 @@ class FileOutputStream;
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "thread/ServiceQueue.h"
|
|
||||||
|
|
||||||
#if BEAST_MSVC
|
#if BEAST_MSVC
|
||||||
#pragma warning (pop)
|
#pragma warning (pop)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user