rippled
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
ripple::LoadManager Class Reference

Manages load sources. More...

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. More...
 
void activateDeadlockDetector ()
 Turn on deadlock detection. More...
 
void resetDeadlockDetector ()
 Reset the deadlock detection timer. More...
 
void start ()
 
void stop ()
 

Private Member Functions

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

Private Attributes

Applicationapp_
 
const beast::Journal journal_
 
std::thread thread_
 
std::mutex mutex_
 
std::condition_variable cv_
 
bool stop_ = false
 
std::chrono::steady_clock::time_point deadLock_
 
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 33 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 38 of file LoadManager.cpp.

Member Function Documentation

◆ operator=()

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

◆ activateDeadlockDetector()

void ripple::LoadManager::activateDeadlockDetector ( )

Turn on deadlock detection.

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

See also
resetDeadlockDetector

Definition at line 55 of file LoadManager.cpp.

◆ resetDeadlockDetector()

void ripple::LoadManager::resetDeadlockDetector ( )

Reset the deadlock detection timer.

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

Definition at line 63 of file LoadManager.cpp.

◆ start()

void ripple::LoadManager::start ( )

Definition at line 73 of file LoadManager.cpp.

◆ stop()

void ripple::LoadManager::stop ( )

Definition at line 82 of file LoadManager.cpp.

◆ run()

void ripple::LoadManager::run ( )
private

Definition at line 100 of file LoadManager.cpp.

Friends And Related Function Documentation

◆ make_LoadManager

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

Definition at line 197 of file LoadManager.cpp.

Member Data Documentation

◆ app_

Application& ripple::LoadManager::app_
private

Definition at line 97 of file LoadManager.h.

◆ journal_

const beast::Journal 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.

◆ deadLock_

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

Definition at line 106 of file LoadManager.h.

◆ armed_

bool ripple::LoadManager::armed_
private

Definition at line 107 of file LoadManager.h.