diff --git a/include/wsrep/chrono.hpp b/include/wsrep/chrono.hpp new file mode 100644 index 0000000..d41a28b --- /dev/null +++ b/include/wsrep/chrono.hpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2019 Codership Oy + * + * 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 . + */ + +/** @file chrono.hpp + * + * Type definitions to work around differences in implementation + * differences between C++11 compatible and ancient compilers. + */ + +#ifndef WSREP_CHRONO_HPP +#define WSREP_CHORNO_HPP + +#include + +namespace wsrep +{ + namespace chrono + { +#if defined(__GNUG__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 4) + template + using time_point = std::chrono::time_point; + using steady_clock = std::chrono::monotonic_clock; +#else + template + using time_point = std::chrono::time_point; + using steady_clock = std::chrono::steady_clock; + } +#endif // defined(__GNUG__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 4) + +} + +#endif // WSREP_CHRONO_HPP diff --git a/include/wsrep/client_state.hpp b/include/wsrep/client_state.hpp index 2944910..06c8816 100644 --- a/include/wsrep/client_state.hpp +++ b/include/wsrep/client_state.hpp @@ -42,8 +42,7 @@ #include "buffer.hpp" #include "thread.hpp" #include "xid.hpp" - -#include +#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 - wait_until = std::chrono::time_point()); + wsrep::chrono::time_point + wait_until = + wsrep::chrono::time_point()); /** * 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 - wait_until = std::chrono::time_point()); + wsrep::chrono::time_point + wait_until = + wsrep::chrono::time_point()); /** * End non-blocking operation phase after aquiring required diff --git a/src/client_state.cpp b/src/client_state.cpp index 1b8fbf0..632c58c 100644 --- a/src/client_state.cpp +++ b/src/client_state.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Codership Oy + * Copyright (C) 2018-2019 Codership Oy * * 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 wait_until) + wsrep::chrono::time_point 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 wait_until) + wsrep::chrono::time_point wait_until) { debug_log_state("begin_nbo_phase_one: enter"); wsrep::unique_lock 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)