1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-28 20:02:00 +03:00

Add type wsrep::xid

Create type `wsrep::xid`, and change all signatures that take
`std::string xid` to take `wsrep::xid xid`.
This commit is contained in:
Daniele Sciascia
2019-10-16 14:06:16 +02:00
parent 682d1b2034
commit 66ee7bed1b
15 changed files with 105 additions and 21 deletions

View File

@ -7,6 +7,7 @@ add_library(wsrep-lib
exception.cpp
gtid.cpp
id.cpp
xid.cpp
key.cpp
logger.cpp
provider.cpp

View File

@ -130,7 +130,7 @@ static int apply_fragment(wsrep::server_state& server_state,
if (!apply_err)
{
high_priority_service.debug_crash("crash_apply_cb_before_append_frag");
const std::string xid(streaming_applier->transaction().xid());
const wsrep::xid xid(streaming_applier->transaction().xid());
ret = high_priority_service.append_fragment_and_commit(
ws_handle, ws_meta, data, xid);
high_priority_service.debug_crash("crash_apply_cb_after_append_frag");
@ -1258,7 +1258,7 @@ wsrep::high_priority_service* wsrep::server_state::find_streaming_applier(
}
wsrep::high_priority_service* wsrep::server_state::find_streaming_applier(
const std::string& xid) const
const wsrep::xid& xid) const
{
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
streaming_appliers_map::const_iterator i(streaming_appliers_.begin());

View File

@ -1040,7 +1040,7 @@ void wsrep::transaction::after_replay(const wsrep::transaction& other)
clear_fragments();
}
int wsrep::transaction::restore_to_prepared_state(const std::string& xid)
int wsrep::transaction::restore_to_prepared_state(const wsrep::xid& xid)
{
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex_);
assert(active());
@ -1053,7 +1053,7 @@ int wsrep::transaction::restore_to_prepared_state(const std::string& xid)
return 0;
}
int wsrep::transaction::commit_or_rollback_by_xid(const std::string& xid,
int wsrep::transaction::commit_or_rollback_by_xid(const wsrep::xid& xid,
bool commit)
{
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex_);

31
src/xid.cpp Normal file
View File

@ -0,0 +1,31 @@
/*
* 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/>.
*/
#include "wsrep/xid.hpp"
#include <ostream>
std::string wsrep::to_string(const wsrep::xid& xid)
{
return xid.xid_;
}
std::ostream& wsrep::operator<<(std::ostream& os, const wsrep::xid& xid)
{
return os << xid.xid_;
}