Guard alias added

master
moneroexamples 8 years ago
parent 13a9060b8b
commit 6e80fc8e24

@ -24,11 +24,8 @@ void
MempoolStatus::start_mempool_status_thread() MempoolStatus::start_mempool_status_thread()
{ {
if (mempool_refresh_time < 1) // to protect from deviation by zero below.
{ mempool_refresh_time = std::max<uint64_t>(1, mempool_refresh_time);
// to protect from diviation by zero below.
mempool_refresh_time = 1;
}
if (!is_running) if (!is_running)
{ {
@ -39,8 +36,7 @@ MempoolStatus::start_mempool_status_thread()
uint64_t loop_index {0}; uint64_t loop_index {0};
// so that network status is checked every minute // so that network status is checked every minute
uint64_t loop_index_divider = 60 / mempool_refresh_time; uint64_t loop_index_divider = std::max<uint64_t>(1, 60 / mempool_refresh_time);
loop_index_divider = loop_index_divider == 0 ? 1 : loop_index_divider;
while (true) while (true)
{ {
@ -192,7 +188,7 @@ MempoolStatus::read_mempool()
std::lock_guard<std::mutex> lck (mempool_mutx); Guard lck (mempool_mutx);
// clear current mempool txs vector // clear current mempool txs vector
// repopulate it with each execution of read_mempool() // repopulate it with each execution of read_mempool()
@ -265,7 +261,7 @@ MempoolStatus::read_network_info()
vector<MempoolStatus::mempool_tx> vector<MempoolStatus::mempool_tx>
MempoolStatus::get_mempool_txs() MempoolStatus::get_mempool_txs()
{ {
std::lock_guard<std::mutex> lck (mempool_mutx); Guard lck (mempool_mutx);
return mempool_txs; return mempool_txs;
} }

@ -22,6 +22,8 @@ namespace xmreg
struct MempoolStatus struct MempoolStatus
{ {
using Guard = std::lock_guard<std::mutex>;
struct mempool_tx struct mempool_tx
{ {
crypto::hash tx_hash; crypto::hash tx_hash;

Loading…
Cancel
Save