File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -161,26 +161,28 @@ struct LogResources
161
161
162
162
/* Flush() two steps strategy:
163
163
164
- I must assure Log::Run swaps the queues because only swapping the queues the background content
164
+ We must assure Log::Run swaps the queues twice
165
+ because its the only way the content in the background queue
165
166
will be consumed (first Run() loop).
166
167
167
- Then, I must assure the new front queue content is consumed (second Run() loop).
168
+ Then, we must assure the new front queue content is consumed (second Run() loop).
168
169
*/
169
170
170
- int last_loop = - 1 ;
171
+ int last_loop = current_loop_ ;
171
172
172
173
for (int i = 0 ; i < 2 ; ++i)
173
174
{
174
175
cv_.wait (guard,
175
176
[&]()
176
177
{
177
- /* I must avoid:
178
- + the two calls be processed without an intermediate Run() loop (by using last_loop sequence number)
178
+ /* We must avoid:
179
+ + the two calls be processed without an intermediate Run() loop
180
+ (by using last_loop sequence number and checking if the foreground queue is empty)
179
181
+ deadlock by absence of Run() loop activity (by using BothEmpty() call)
180
182
*/
181
183
return !logging_ ||
182
- ( logs_.Empty () &&
183
- (last_loop != current_loop_ || logs_.BothEmpty () ));
184
+ logs_.BothEmpty () ||
185
+ (last_loop != current_loop_ && logs_.Empty ( ));
184
186
});
185
187
186
188
last_loop = current_loop_;
You can’t perform that action at this time.
0 commit comments