File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed
ydb/public/sdk/cpp/src/client Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -834,6 +834,8 @@ class TTransaction::TImpl : public std::enable_shared_from_this<TImpl> {
834
834
}
835
835
836
836
void AddPrecommitCallback (TPrecommitTransactionCallback cb) {
837
+ std::lock_guard lock (PrecommitCallbacksMutex);
838
+
837
839
if (!ChangesAreAccepted) {
838
840
ythrow TContractViolation (" Changes are no longer accepted" );
839
841
}
@@ -842,6 +844,8 @@ class TTransaction::TImpl : public std::enable_shared_from_this<TImpl> {
842
844
}
843
845
844
846
void AddOnFailureCallback (TOnFailureTransactionCallback cb) {
847
+ std::lock_guard lock (OnFailureCallbacksMutex);
848
+
845
849
if (!ChangesAreAccepted) {
846
850
ythrow TContractViolation (" Changes are no longer accepted" );
847
851
}
@@ -856,6 +860,9 @@ class TTransaction::TImpl : public std::enable_shared_from_this<TImpl> {
856
860
bool ChangesAreAccepted = true ; // haven't called Commit or Rollback yet
857
861
std::vector<TPrecommitTransactionCallback> PrecommitCallbacks;
858
862
std::vector<TOnFailureTransactionCallback> OnFailureCallbacks;
863
+
864
+ std::mutex PrecommitCallbacksMutex;
865
+ std::mutex OnFailureCallbacksMutex;
859
866
};
860
867
861
868
TTransaction::TTransaction (const TSession& session, const std::string& txId)
Original file line number Diff line number Diff line change @@ -92,6 +92,8 @@ TAsyncStatus TTransaction::TImpl::Rollback(const TRollbackTxSettings& settings)
92
92
93
93
void TTransaction::TImpl::AddPrecommitCallback (TPrecommitTransactionCallback cb)
94
94
{
95
+ std::lock_guard lock (PrecommitCallbacksMutex);
96
+
95
97
if (!ChangesAreAccepted) {
96
98
ythrow TContractViolation (" Changes are no longer accepted" );
97
99
}
@@ -101,6 +103,8 @@ void TTransaction::TImpl::AddPrecommitCallback(TPrecommitTransactionCallback cb)
101
103
102
104
void TTransaction::TImpl::AddOnFailureCallback (TOnFailureTransactionCallback cb)
103
105
{
106
+ std::lock_guard lock (OnFailureCallbacksMutex);
107
+
104
108
if (!ChangesAreAccepted) {
105
109
ythrow TContractViolation (" Changes are no longer accepted" );
106
110
}
Original file line number Diff line number Diff line change 2
2
3
3
#include < ydb/public/sdk/cpp/include/ydb-cpp-sdk/client/table/table.h>
4
4
5
+ #include < mutex>
6
+
5
7
namespace NYdb ::inline Dev::NTable {
6
8
7
9
class TTransaction ::TImpl : public std::enable_shared_from_this<TImpl> {
@@ -40,6 +42,9 @@ class TTransaction::TImpl : public std::enable_shared_from_this<TImpl> {
40
42
bool ChangesAreAccepted = true ; // haven't called Commit or Rollback yet
41
43
mutable std::vector<TPrecommitTransactionCallback> PrecommitCallbacks;
42
44
mutable std::vector<TOnFailureTransactionCallback> OnFailureCallbacks;
45
+
46
+ std::mutex PrecommitCallbacksMutex;
47
+ std::mutex OnFailureCallbacksMutex;
43
48
};
44
49
45
50
}
You can’t perform that action at this time.
0 commit comments