Make some methods const. Remove outdated TODO

This commit is contained in:
Tyler Neely 2022-08-01 10:30:37 +00:00
parent b127f6f345
commit 9b915be1aa
4 changed files with 9 additions and 10 deletions

View File

@ -30,8 +30,8 @@ namespace memgraph::io {
namespace {
template <typename T>
class Shared {
std::condition_variable cv_;
std::mutex mu_;
mutable std::condition_variable cv_;
mutable std::mutex mu_;
std::optional<T> item_;
bool consumed_ = false;
bool waiting_ = false;

View File

@ -205,8 +205,8 @@ struct DeadlineAndOpaquePromise {
};
class SimulatorHandle {
std::mutex mu_{};
std::condition_variable cv_;
mutable std::mutex mu_{};
mutable std::condition_variable cv_;
// messages that have not yet been scheduled or dropped
std::vector<std::pair<Address, OpaqueMessage>> in_flight_;
@ -258,7 +258,6 @@ class SimulatorHandle {
const Time now = cluster_wide_time_microseconds_;
for (auto &[promise_key, dop] : promises_) {
// TODO(tyler) queue this up and drop it after its deadline
if (dop.deadline < now) {
spdlog::debug("timing out request from requester {} to replier {}.", promise_key.requester_address.ToString(),
promise_key.replier_address.ToString());

View File

@ -25,7 +25,7 @@ using memgraph::io::Time;
class SimulatorTransport {
std::shared_ptr<SimulatorHandle> simulator_handle_;
Address address_;
const Address address_;
std::mt19937 rng_{};
public:
@ -53,9 +53,9 @@ class SimulatorTransport {
return simulator_handle_->template Send<M>(address, address_, request_id, message);
}
Time Now() { return simulator_handle_->Now(); }
Time Now() const { return simulator_handle_->Now(); }
bool ShouldShutDown() { return simulator_handle_->ShouldShutDown(); }
bool ShouldShutDown() const { return simulator_handle_->ShouldShutDown(); }
template <class D = std::poisson_distribution<>, class Return = uint64_t>
Return Rand(D distrib) {

View File

@ -112,10 +112,10 @@ class Io {
/// This time source should be preferred over any other, because it
/// lets us deterministically control clocks from tests for making
/// things like timeouts deterministic.
Time Now() { return implementation_.Now(); }
Time Now() const { return implementation_.Now(); }
/// Returns true of the system should shut-down.
const bool ShouldShutDown() { return implementation_.ShouldShutDown(); }
bool ShouldShutDown() const { return implementation_.ShouldShutDown(); }
/// Returns a random number within the specified distribution.
template <class D = std::poisson_distribution<>, class Return = uint64_t>