rippled
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
ripple::LoadManager Class Reference

Manages load sources. More...

#include <LoadManager.h>

Collaboration diagram for ripple::LoadManager:
Collaboration graph
[legend]

Public Member Functions

 LoadManager ()=delete
 
 LoadManager (LoadManager const &)=delete
 
LoadManageroperator= (LoadManager const &)=delete
 
 ~LoadManager ()
 Destroy the manager.
 
void activateStallDetector ()
 Turn on stall detection.
 
void heartbeat ()
 Reset the stall detection timer.
 
void start ()
 
void stop ()
 

Private Member Functions

 LoadManager (Application &app, beast::Journal journal)
 
void run ()
 

Private Attributes

Applicationapp_
 
beast::Journal const journal_
 
std::thread thread_
 
std::mutex mutex_
 
std::condition_variable cv_
 
bool stop_ = false
 
std::chrono::steady_clock::time_point lastHeartbeat_
 
bool armed_
 

Friends

std::unique_ptr< LoadManagermake_LoadManager (Application &app, beast::Journal journal)
 

Detailed Description

Manages load sources.

This object creates an associated thread to maintain a clock.

When the server is overloaded by a particular peer it issues a warning first. This allows friendly peers to reduce their consumption of resources, or disconnect from the server.

The warning system is used instead of merely dropping, because hostile peers can just reconnect anyway.

Definition at line 45 of file LoadManager.h.

Constructor & Destructor Documentation

◆ LoadManager() [1/3]

ripple::LoadManager::LoadManager ( Application app,
beast::Journal  journal 
)
private

Definition at line 34 of file LoadManager.cpp.

◆ LoadManager() [2/3]

ripple::LoadManager::LoadManager ( )
delete

◆ LoadManager() [3/3]

ripple::LoadManager::LoadManager ( LoadManager const &  )
delete

◆ ~LoadManager()

ripple::LoadManager::~LoadManager ( )

Destroy the manager.

The destructor returns only after the thread has stopped.

Definition at line 39 of file LoadManager.cpp.

Member Function Documentation

◆ operator=()

LoadManager & ripple::LoadManager::operator= ( LoadManager const &  )
delete

◆ activateStallDetector()

void ripple::LoadManager::activateStallDetector ( )

Turn on stall detection.

The stall detector begins in a disabled state. After this function is called, it will report stalls using a separate thread whenever the reset function is not called at least once per 10 seconds.

See also
resetStallDetector

Definition at line 56 of file LoadManager.cpp.

◆ heartbeat()

void ripple::LoadManager::heartbeat ( )

Reset the stall detection timer.

A dedicated thread monitors the stall timer, and if too much time passes it will produce log warnings.

Definition at line 64 of file LoadManager.cpp.

◆ start()

void ripple::LoadManager::start ( )

Definition at line 74 of file LoadManager.cpp.

◆ stop()

void ripple::LoadManager::stop ( )

Definition at line 85 of file LoadManager.cpp.

◆ run()

void ripple::LoadManager::run ( )
private

Definition at line 103 of file LoadManager.cpp.

Friends And Related Symbol Documentation

◆ make_LoadManager

std::unique_ptr< LoadManager > make_LoadManager ( Application app,
beast::Journal  journal 
)
friend

Definition at line 199 of file LoadManager.cpp.

Member Data Documentation

◆ app_

Application& ripple::LoadManager::app_
private

Definition at line 97 of file LoadManager.h.

◆ journal_

beast::Journal const ripple::LoadManager::journal_
private

Definition at line 98 of file LoadManager.h.

◆ thread_

std::thread ripple::LoadManager::thread_
private

Definition at line 100 of file LoadManager.h.

◆ mutex_

std::mutex ripple::LoadManager::mutex_
private

Definition at line 101 of file LoadManager.h.

◆ cv_

std::condition_variable ripple::LoadManager::cv_
private

Definition at line 102 of file LoadManager.h.

◆ stop_

bool ripple::LoadManager::stop_ = false
private

Definition at line 103 of file LoadManager.h.

◆ lastHeartbeat_

std::chrono::steady_clock::time_point ripple::LoadManager::lastHeartbeat_
private

Definition at line 106 of file LoadManager.h.

◆ armed_

bool ripple::LoadManager::armed_
private

Definition at line 107 of file LoadManager.h.