mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Replace obsolete OncePerSecond with DeadlineTimer
This commit is contained in:
@@ -213,7 +213,6 @@ namespace beast
|
||||
|
||||
#include "thread/impl/TrackedMutex.cpp"
|
||||
#include "thread/beast_DeadlineTimer.cpp"
|
||||
#include "thread/beast_OncePerSecond.cpp"
|
||||
#include "thread/beast_InterruptibleThread.cpp"
|
||||
#include "thread/beast_Semaphore.cpp"
|
||||
#include "thread/beast_CallQueue.cpp"
|
||||
|
||||
@@ -409,7 +409,6 @@ extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) n
|
||||
#include "functional/beast_Function.h"
|
||||
|
||||
#include "thread/beast_DeadlineTimer.h"
|
||||
#include "thread/beast_OncePerSecond.h"
|
||||
|
||||
#include "memory/beast_AllocatedBy.h"
|
||||
#include "memory/beast_PagedFreeStore.h"
|
||||
|
||||
@@ -81,7 +81,8 @@ inline PagedFreeStore::Page* PagedFreeStore::toPage (void* const p)
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
PagedFreeStore::PagedFreeStore (const size_t pageBytes)
|
||||
: m_pageBytes (pageBytes)
|
||||
: m_timer (this)
|
||||
, m_pageBytes (pageBytes)
|
||||
, m_pageBytesAvailable (pageBytes - Memory::sizeAdjustedForAlignment (sizeof (Page)))
|
||||
, m_newPagesLeft (int ((hardLimitMegaBytes * 1024 * 1024) / m_pageBytes))
|
||||
#if LOG_GC
|
||||
@@ -91,12 +92,12 @@ PagedFreeStore::PagedFreeStore (const size_t pageBytes)
|
||||
m_hot = m_pool1;
|
||||
m_cold = m_pool2;
|
||||
|
||||
startOncePerSecond ();
|
||||
m_timer.setExpiration (1.0);
|
||||
}
|
||||
|
||||
PagedFreeStore::~PagedFreeStore ()
|
||||
{
|
||||
endOncePerSecond ();
|
||||
m_timer.reset ();
|
||||
|
||||
#if LOG_GC
|
||||
bassert (!m_used.isSignaled ());
|
||||
@@ -162,7 +163,7 @@ void PagedFreeStore::deallocate (void* const p)
|
||||
//
|
||||
// Perform garbage collection.
|
||||
//
|
||||
void PagedFreeStore::doOncePerSecond ()
|
||||
void PagedFreeStore::onDeadlineTimer (DeadlineTimer&)
|
||||
{
|
||||
// Physically free one page.
|
||||
// This will reduce the working set over time after a spike.
|
||||
@@ -195,6 +196,8 @@ void PagedFreeStore::doOncePerSecond ()
|
||||
<< String (m_newPagesLeft.get ()) << ")";
|
||||
Logger::outputDebugString (s);
|
||||
#endif
|
||||
|
||||
m_timer.setExpiration (1.0);
|
||||
}
|
||||
|
||||
void PagedFreeStore::dispose (Pages& pages)
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
@ingroup beast_concurrent
|
||||
*/
|
||||
class BEAST_API PagedFreeStore : private OncePerSecond
|
||||
class BEAST_API PagedFreeStore : private DeadlineTimer::Listener
|
||||
{
|
||||
public:
|
||||
explicit PagedFreeStore (const size_t pageBytes);
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
|
||||
private:
|
||||
void* newPage ();
|
||||
void doOncePerSecond ();
|
||||
void onDeadlineTimer (DeadlineTimer&);
|
||||
|
||||
private:
|
||||
struct Page;
|
||||
@@ -75,6 +75,7 @@ private:
|
||||
void dispose (Pool& pool);
|
||||
|
||||
private:
|
||||
DeadlineTimer m_timer;
|
||||
const size_t m_pageBytes;
|
||||
const size_t m_pageBytesAvailable;
|
||||
CacheLine::Aligned <Pool> m_pool1; // pair of pools
|
||||
|
||||
Reference in New Issue
Block a user