mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
General refactoring, using C++11
* Remove broken RecycledObjectPool * Fix beast::ServiceQueue using List instead of LockFreeStack * Add class semaphore, fixes broken Semaphore * Move crytpo module files to new beast directory * Use c++11 replacements for boost and beast types: - std::atomic instead of beast::Atomic - std::function instead of boost::function, beast::function - std::unique_ptr instead of beast::ScopedPointer - std::shared_ptr instead of boost::shared_ptr * Remove modules: - beast_db - beast_crypto - beast_extras * Remove unnecessary classes: - AbstractFifo - AddConst - AtomicCounter - AtomicFlag - AtomicPointer - AtomicState - CopyConst - Expression - ForwardList - IfCond - Interval - IntrusiveArray - KeyvaDB - PointerToOther - PointerTraits - RemoveConst - RemoveConstVolatile - RemoveReference - RemoveVolatile - SharedObjectArray - SingleThreadedSharedObject - SophiaDB factory - SortedSet - WeakReference - beast::unique_ptr
This commit is contained in:
@@ -119,12 +119,11 @@ void ServiceQueueBase::stop ()
|
||||
{
|
||||
SharedState::Access state (m_state);
|
||||
m_stopped.set (1);
|
||||
for(;;)
|
||||
while (! state->waiting.empty ())
|
||||
{
|
||||
Waiter* waiting (state->waiting.pop_front());
|
||||
if (waiting == nullptr)
|
||||
break;
|
||||
waiting->signal();
|
||||
Waiter& waiting (state->waiting.front());
|
||||
state->waiting.pop_front ();
|
||||
waiting.signal ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,14 +143,24 @@ void ServiceQueueBase::wait ()
|
||||
|
||||
{
|
||||
SharedState::Access state (m_state);
|
||||
|
||||
if (stopped ())
|
||||
return;
|
||||
|
||||
if (! state->handlers.empty())
|
||||
return;
|
||||
waiter = state->unused.pop_front();
|
||||
if (! waiter)
|
||||
|
||||
if (state->unused.empty ())
|
||||
{
|
||||
waiter = new_waiter();
|
||||
state->waiting.push_front (waiter);
|
||||
}
|
||||
else
|
||||
{
|
||||
waiter = &state->unused.front ();
|
||||
state->unused.pop_front ();
|
||||
}
|
||||
|
||||
state->waiting.push_front (*waiter);
|
||||
}
|
||||
|
||||
waiter->wait();
|
||||
@@ -160,19 +169,22 @@ void ServiceQueueBase::wait ()
|
||||
|
||||
{
|
||||
SharedState::Access state (m_state);
|
||||
state->unused.push_front (waiter);
|
||||
state->unused.push_front (*waiter);
|
||||
}
|
||||
}
|
||||
|
||||
void ServiceQueueBase::enqueue (Item* item)
|
||||
{
|
||||
Waiter* waiter;
|
||||
Waiter* waiter (nullptr);
|
||||
|
||||
{
|
||||
SharedState::Access state (m_state);
|
||||
state->handlers.push_back (*item);
|
||||
// Signal a Waiter if one exists
|
||||
waiter = state->waiting.pop_front();
|
||||
if (! state->waiting.empty ())
|
||||
{
|
||||
waiter = &state->waiting.front ();
|
||||
state->waiting.pop_front ();
|
||||
}
|
||||
}
|
||||
|
||||
if (waiter != nullptr)
|
||||
|
||||
Reference in New Issue
Block a user