mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-06-13 04:01:32 +03:00
Chrono definitions to work around g++ 4.4 C++11 incompatibilities.
This commit is contained in:
48
include/wsrep/chrono.hpp
Normal file
48
include/wsrep/chrono.hpp
Normal 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
|
@ -42,8 +42,7 @@
|
|||||||
#include "buffer.hpp"
|
#include "buffer.hpp"
|
||||||
#include "thread.hpp"
|
#include "thread.hpp"
|
||||||
#include "xid.hpp"
|
#include "xid.hpp"
|
||||||
|
#include "chrono.hpp"
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
namespace wsrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
@ -684,8 +683,9 @@ namespace wsrep
|
|||||||
int enter_toi_local(
|
int enter_toi_local(
|
||||||
const wsrep::key_array& key_array,
|
const wsrep::key_array& key_array,
|
||||||
const wsrep::const_buffer& buffer,
|
const wsrep::const_buffer& buffer,
|
||||||
std::chrono::time_point<std::chrono::steady_clock>
|
wsrep::chrono::time_point<wsrep::chrono::steady_clock>
|
||||||
wait_until = std::chrono::time_point<std::chrono::steady_clock>());
|
wait_until =
|
||||||
|
wsrep::chrono::time_point<wsrep::chrono::steady_clock>());
|
||||||
/**
|
/**
|
||||||
* Enter applier TOI mode
|
* Enter applier TOI mode
|
||||||
*
|
*
|
||||||
@ -759,8 +759,9 @@ namespace wsrep
|
|||||||
int begin_nbo_phase_one(
|
int begin_nbo_phase_one(
|
||||||
const wsrep::key_array& keys,
|
const wsrep::key_array& keys,
|
||||||
const wsrep::const_buffer& buffer,
|
const wsrep::const_buffer& buffer,
|
||||||
std::chrono::time_point<std::chrono::steady_clock>
|
wsrep::chrono::time_point<wsrep::chrono::steady_clock>
|
||||||
wait_until = std::chrono::time_point<std::chrono::steady_clock>());
|
wait_until =
|
||||||
|
wsrep::chrono::time_point<wsrep::chrono::steady_clock>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* End non-blocking operation phase after aquiring required
|
* End non-blocking operation phase after aquiring required
|
||||||
|
@ -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.
|
* 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,
|
int wsrep::client_state::enter_toi_local(const wsrep::key_array& keys,
|
||||||
const wsrep::const_buffer& buffer,
|
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");
|
debug_log_state("enter_toi_local: enter");
|
||||||
assert(state_ == s_exec);
|
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 &&
|
while (status == wsrep::provider::error_certification_failed &&
|
||||||
wait_until.time_since_epoch().count() &&
|
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));
|
not client_service_.interrupted(lock));
|
||||||
|
|
||||||
switch (status)
|
switch (status)
|
||||||
@ -477,7 +477,7 @@ int wsrep::client_state::end_rsu()
|
|||||||
int wsrep::client_state::begin_nbo_phase_one(
|
int wsrep::client_state::begin_nbo_phase_one(
|
||||||
const wsrep::key_array& keys,
|
const wsrep::key_array& keys,
|
||||||
const wsrep::const_buffer& buffer,
|
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");
|
debug_log_state("begin_nbo_phase_one: enter");
|
||||||
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
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 &&
|
while (status == wsrep::provider::error_certification_failed &&
|
||||||
wait_until.time_since_epoch().count() &&
|
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));
|
not client_service_.interrupted(lock));
|
||||||
int ret;
|
int ret;
|
||||||
switch (status)
|
switch (status)
|
||||||
|
Reference in New Issue
Block a user