Apache Ignite C++ Client
Loading...
Searching...
No Matches
transaction.h
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
20#include "ignite/common/detail/config.h"
21#include "ignite/common/ignite_result.h"
22
23namespace ignite {
24
25namespace detail {
26class sql_impl;
27class table_impl;
28class transaction_impl;
29class transactions_impl;
30}
31
35class transaction {
36 friend class detail::sql_impl;
37 friend class detail::table_impl;
38 friend class detail::transactions_impl;
39
40public:
41 // Default
42 transaction() = default;
43
47 IGNITE_API void commit() {
48 return sync<void>([this](const auto& callback) { commit_async(std::move(callback)); });
49 }
50
56 IGNITE_API void commit_async(const ignite_callback<void> &callback);
57
61 IGNITE_API void rollback() {
62 sync<void>([this](const auto& callback) { rollback_async(std::move(callback)); });
63 }
64
70 IGNITE_API void rollback_async(const ignite_callback<void> &callback);
71
72private:
78 explicit transaction(std::shared_ptr<detail::transaction_impl> impl)
79 : m_impl(std::move(impl)) {}
80
82 std::shared_ptr<detail::transaction_impl> m_impl;
83};
84
85} // namespace ignite
Definition transaction.h:35
IGNITE_API void rollback_async(const ignite_callback< void > &callback)
Definition transaction.cpp:27
IGNITE_API void rollback()
Definition transaction.h:61
IGNITE_API void commit()
Definition transaction.h:47
IGNITE_API void commit_async(const ignite_callback< void > &callback)
Definition transaction.cpp:23