1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-06-11 16:48:11 +03:00

Chrono definitions to work around g++ 4.4 C++11 incompatibilities.

This commit is contained in:
Teemu Ollakka
2019-09-04 15:50:44 +03:00
parent 55fdbb7a05
commit b05abb005f
3 changed files with 60 additions and 11 deletions

48
include/wsrep/chrono.hpp Normal file
View File

@ -0,0 +1,48 @@
/*
* Copyright (C) 2019 Codership Oy <info@codership.com>
*
* This file is part of wsrep-lib.
*
* Wsrep-lib is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Wsrep-lib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with wsrep-lib. If not, see <https://www.gnu.org/licenses/>.
*/
/** @file chrono.hpp
*
* Type definitions to work around differences in <chrono> implementation
* differences between C++11 compatible and ancient compilers.
*/
#ifndef WSREP_CHRONO_HPP
#define WSREP_CHORNO_HPP
#include <chrono>
namespace wsrep
{
namespace chrono
{
#if defined(__GNUG__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 4)
template <typename T>
using time_point = std::chrono::time_point<T>;
using steady_clock = std::chrono::monotonic_clock;
#else
template <typename T>
using time_point = std::chrono::time_point<T>;
using steady_clock = std::chrono::steady_clock;
}
#endif // defined(__GNUG__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 4)
}
#endif // WSREP_CHRONO_HPP

View File

@ -42,8 +42,7 @@
#include "buffer.hpp"
#include "thread.hpp"
#include "xid.hpp"
#include <chrono>
#include "chrono.hpp"
namespace wsrep
{
@ -684,8 +683,9 @@ namespace wsrep
int enter_toi_local(
const wsrep::key_array& key_array,
const wsrep::const_buffer& buffer,
std::chrono::time_point<std::chrono::steady_clock>
wait_until = std::chrono::time_point<std::chrono::steady_clock>());
wsrep::chrono::time_point<wsrep::chrono::steady_clock>
wait_until =
wsrep::chrono::time_point<wsrep::chrono::steady_clock>());
/**
* Enter applier TOI mode
*
@ -759,8 +759,9 @@ namespace wsrep
int begin_nbo_phase_one(
const wsrep::key_array& keys,
const wsrep::const_buffer& buffer,
std::chrono::time_point<std::chrono::steady_clock>
wait_until = std::chrono::time_point<std::chrono::steady_clock>());
wsrep::chrono::time_point<wsrep::chrono::steady_clock>
wait_until =
wsrep::chrono::time_point<wsrep::chrono::steady_clock>());
/**
* End non-blocking operation phase after aquiring required

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Codership Oy <info@codership.com>
* Copyright (C) 2018-2019 Codership Oy <info@codership.com>
*
* This file is part of wsrep-lib.
*
@ -340,7 +340,7 @@ void wsrep::client_state::enter_toi_common(
int wsrep::client_state::enter_toi_local(const wsrep::key_array& keys,
const wsrep::const_buffer& buffer,
std::chrono::time_point<std::chrono::steady_clock> wait_until)
wsrep::chrono::time_point<wsrep::chrono::steady_clock> wait_until)
{
debug_log_state("enter_toi_local: enter");
assert(state_ == s_exec);
@ -360,7 +360,7 @@ int wsrep::client_state::enter_toi_local(const wsrep::key_array& keys,
}
while (status == wsrep::provider::error_certification_failed &&
wait_until.time_since_epoch().count() &&
wait_until < std::chrono::steady_clock::now() &&
wait_until < wsrep::chrono::steady_clock::now() &&
not client_service_.interrupted(lock));
switch (status)
@ -477,7 +477,7 @@ int wsrep::client_state::end_rsu()
int wsrep::client_state::begin_nbo_phase_one(
const wsrep::key_array& keys,
const wsrep::const_buffer& buffer,
std::chrono::time_point<std::chrono::steady_clock> wait_until)
wsrep::chrono::time_point<wsrep::chrono::steady_clock> wait_until)
{
debug_log_state("begin_nbo_phase_one: enter");
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
@ -496,7 +496,7 @@ int wsrep::client_state::begin_nbo_phase_one(
}
while (status == wsrep::provider::error_certification_failed &&
wait_until.time_since_epoch().count() &&
wait_until < std::chrono::steady_clock::now() &&
wait_until < wsrep::chrono::steady_clock::now() &&
not client_service_.interrupted(lock));
int ret;
switch (status)