| Apache Ignite C++

thin-client/include/ignite/thin/transactions/transactions.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 #ifndef _IGNITE_THIN_TRANSACTIONS_CLIENT_TRANSACTIONS
19 #define _IGNITE_THIN_TRANSACTIONS_CLIENT_TRANSACTIONS
20
21 #include <string>
22
23 #include <ignite/common/concurrent.h>
24 #include <ignite/common/fixed_size_array.h>
25 #include <ignite/impl/thin/transactions/transactions_proxy.h>
26 #include "ignite/thin/transactions/transaction.h"
27
28 namespace ignite
29 {
30 namespace thin
31 {
32 namespace transactions
33 {
43 class ClientTransactions {
44 public:
50 ClientTransactions(ignite::common::concurrent::SharedPointer<void> impl) :
51 proxy(impl),
52 label(ignite::common::concurrent::SharedPointer<ignite::common::FixedSizeArray<char> >())
53 {
54 // No-op.
55 }
56
60 ClientTransactions()
61 {
62 // No-op.
63 }
64
68 ~ClientTransactions()
69 {
70 // No-op.
71 }
72
83 ClientTransaction TxStart(
84 TransactionConcurrency::Type concurrency = TransactionConcurrency::PESSIMISTIC,
85 TransactionIsolation::Type isolation = TransactionIsolation::READ_COMMITTED,
86 int64_t timeout = 0,
87 int32_t txSize = 0)
88 {
89 return ClientTransaction(proxy.txStart(concurrency, isolation, timeout, txSize, label));
90 }
91
98 ClientTransactions withLabel(const std::string& lbl)
99 {
100 ClientTransactions copy = ClientTransactions(proxy, lbl);
101
102 return copy;
103 }
104 private:
106 ignite::impl::thin::transactions::TransactionsProxy proxy;
107
109 ignite::common::concurrent::SharedPointer<ignite::common::FixedSizeArray<char> > label;
110
116 ClientTransactions(ignite::impl::thin::transactions::TransactionsProxy& impl, const std::string& lbl) :
117 proxy(impl)
118 {
119 ignite::common::FixedSizeArray<char> *label0 =
120 new ignite::common::FixedSizeArray<char>(static_cast<int32_t>(lbl.size()) + 1);
121
122 strcpy(label0->GetData(), lbl.c_str());
123
124 label = ignite::common::concurrent::SharedPointer<ignite::common::FixedSizeArray<char> >(label0);
125 }
126 };
127 }
128 }
129 }
130
131 #endif // _IGNITE_THIN_TRANSACTIONS_CLIENT_TRANSACTION
ignite::thin::transactions::ClientTransactions::ClientTransactions
ClientTransactions()
Default constructor.
Definition: thin-client/include/ignite/thin/transactions/transactions.h:60
ignite::thin::transactions::ClientTransactions::withLabel
ClientTransactions withLabel(const std::string &lbl)
Returns instance of.
Definition: thin-client/include/ignite/thin/transactions/transactions.h:98
ignite::thin::transactions::TransactionConcurrency::Type
Type
Definition: thin-client/include/ignite/thin/transactions/transaction_consts.h:36
ignite::thin::transactions::ClientTransaction
Transaction client.
Definition: thin-client/include/ignite/thin/transactions/transaction.h:38
ignite::thin::transactions::ClientTransactions::ClientTransactions
ClientTransactions(ignite::common::concurrent::SharedPointer< void > impl)
Constructor.
Definition: thin-client/include/ignite/thin/transactions/transactions.h:50
ignite::thin::transactions::ClientTransactions::TxStart
ClientTransaction TxStart(TransactionConcurrency::Type concurrency=TransactionConcurrency::PESSIMISTIC, TransactionIsolation::Type isolation=TransactionIsolation::READ_COMMITTED, int64_t timeout=0, int32_t txSize=0)
Start new transaction with completely clarify parameters.
Definition: thin-client/include/ignite/thin/transactions/transactions.h:83
ignite::thin::transactions::TransactionIsolation::READ_COMMITTED
Read committed isolation level.
Definition: thin-client/include/ignite/thin/transactions/transaction_consts.h:86
ignite::thin::transactions::ClientTransactions::~ClientTransactions
~ClientTransactions()
Destructor.
Definition: thin-client/include/ignite/thin/transactions/transactions.h:68
ignite::thin::transactions::TransactionConcurrency::PESSIMISTIC
Pessimistic concurrency model.
Definition: thin-client/include/ignite/thin/transactions/transaction_consts.h:65
ignite::thin::transactions::ClientTransactions
Transactions client.
Definition: thin-client/include/ignite/thin/transactions/transactions.h:43
ignite::thin::transactions::TransactionIsolation::Type
Type
Definition: thin-client/include/ignite/thin/transactions/transaction_consts.h:74
ignite
Apache Ignite API.
Definition: cache.h:48