Files
rippled/include/xrpl/core/LoadEvent.h
Bart 34ef577604 refactor: Replace include guards by '#pragma once' (#6322)
This change replaces all include guards in the `src/` and `include/` directories by `#pragma once`.
2026-02-04 09:50:21 -05:00

68 lines
1.5 KiB
C++

#pragma once
#include <chrono>
#include <string>
namespace xrpl {
class LoadMonitor;
// VFALCO NOTE What is the difference between a LoadEvent and a LoadMonitor?
// VFALCO TODO Rename LoadEvent to ScopedLoadSample
//
// This looks like a scoped elapsed time measuring class
//
class LoadEvent
{
public:
// VFALCO TODO remove the dependency on LoadMonitor. Is that possible?
LoadEvent(LoadMonitor& monitor, std::string const& name, bool shouldStart);
LoadEvent(LoadEvent const&) = delete;
~LoadEvent();
std::string const&
name() const;
// The time spent waiting.
std::chrono::steady_clock::duration
waitTime() const;
// The time spent running.
std::chrono::steady_clock::duration
runTime() const;
void
setName(std::string const& name);
// Start the measurement. If already started, then
// restart, assigning the elapsed time to the "waiting"
// state.
void
start();
// Stop the measurement and report the results. The
// time reported is measured from the last call to
// start.
void
stop();
private:
LoadMonitor& monitor_;
// Represents our current state
bool running_;
// The name associated with this event, if any.
std::string name_;
// Represents the time we last transitioned states
std::chrono::steady_clock::time_point mark_;
// The time we spent waiting and running respectively
std::chrono::steady_clock::duration timeWaiting_;
std::chrono::steady_clock::duration timeRunning_;
};
} // namespace xrpl