File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
yql/essentials/core/qplayer/storage/interface Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -7,11 +7,15 @@ class TQWriterDecorator : public IQWriter {
7
7
public:
8
8
TQWriterDecorator (IQWriterPtr&& underlying) : Underlying_(std::move(underlying)) {}
9
9
NThreading::TFuture<void > Put (const TQItemKey& key, const TString& value) override final {
10
+ decltype (Underlying_) underlying;
11
+ with_lock (Mutex_) {
12
+ underlying = Underlying_;
13
+ }
10
14
if (Closed_) {
11
15
return NThreading::MakeFuture ();
12
16
}
13
17
try {
14
- return Underlying_ ->Put (key, value);
18
+ return underlying ->Put (key, value);
15
19
} catch (...) {
16
20
auto message = CurrentExceptionMessage ();
17
21
with_lock (Mutex_) {
@@ -32,16 +36,24 @@ class TQWriterDecorator : public IQWriter {
32
36
if (!Closed_.compare_exchange_strong (expected, true )) {
33
37
throw yexception () << " QWriter closed" ;
34
38
}
35
- auto result = Underlying_->Commit ();
36
- Underlying_ = {};
39
+ decltype (Underlying_) underlying;
40
+ with_lock (Mutex_) {
41
+ underlying = Underlying_;
42
+ }
43
+ auto result = underlying->Commit ();
44
+ with_lock (Mutex_) {
45
+ Underlying_ = {};
46
+ }
37
47
return result;
38
48
}
39
49
40
50
// Close all used files, doesn't commit anything
41
51
void Close () override final {
42
52
bool expected = false ;
43
53
if (Closed_.compare_exchange_strong (expected, true )) {
44
- Underlying_ = {};
54
+ with_lock (Mutex_) {
55
+ Underlying_ = {};
56
+ }
45
57
}
46
58
}
47
59
private:
You can’t perform that action at this time.
0 commit comments