rippled
Loading...
Searching...
No Matches
LoadManager.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_APP_MAIN_LOADMANAGER_H_INCLUDED
21#define RIPPLE_APP_MAIN_LOADMANAGER_H_INCLUDED
22
23#include <xrpl/beast/utility/Journal.h>
24
25#include <atomic>
26#include <memory>
27#include <mutex>
28#include <thread>
29
30namespace ripple {
31
32class Application;
33
46{
48
49public:
50 LoadManager() = delete;
51 LoadManager(LoadManager const&) = delete;
53 operator=(LoadManager const&) = delete;
54
60
69 // VFALCO NOTE it seems that the stall detector has an "armed" state
70 // to prevent it from going off during program startup if
71 // there's a lengthy initialization operation taking place?
72 //
73 void
75
81 void
82 heartbeat();
83
84 //--------------------------------------------------------------------------
85
86 void
87 start();
88
89 void
90 stop();
91
92private:
93 void
94 run();
95
96private:
99
101 std::mutex mutex_; // Guards lastHeartbeat_, armed_, cv_
103 bool stop_ = false;
104
105 // Detect server stalls
106 std::chrono::steady_clock::time_point lastHeartbeat_;
107 bool armed_;
108
111};
112
115
116} // namespace ripple
117
118#endif
A generic endpoint for log messages.
Definition Journal.h:60
Manages load sources.
Definition LoadManager.h:46
LoadManager & operator=(LoadManager const &)=delete
std::chrono::steady_clock::time_point lastHeartbeat_
std::condition_variable cv_
std::thread thread_
void activateStallDetector()
Turn on stall detection.
LoadManager(LoadManager const &)=delete
beast::Journal const journal_
Definition LoadManager.h:98
Application & app_
Definition LoadManager.h:97
void heartbeat()
Reset the stall detection timer.
~LoadManager()
Destroy the manager.
friend std::unique_ptr< LoadManager > make_LoadManager(Application &app, beast::Journal journal)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
std::unique_ptr< LoadManager > make_LoadManager(Application &app, beast::Journal journal)