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 @@ -174,26 +174,28 @@ struct LogResources
174
174
175
175
/* Flush() two steps strategy:
176
176
177
- I must assure Log::Run swaps the queues because only swapping the queues the background content
177
+ We must assure Log::Run swaps the queues twice
178
+ because its the only way the content in the background queue
178
179
will be consumed (first Run() loop).
179
180
180
- Then, I must assure the new front queue content is consumed (second Run() loop).
181
+ Then, we must assure the new front queue content is consumed (second Run() loop).
181
182
*/
182
183
183
- int last_loop = - 1 ;
184
+ int last_loop = current_loop_ ;
184
185
185
186
for (int i = 0 ; i < 2 ; ++i)
186
187
{
187
188
cv_.wait (guard,
188
189
[&]()
189
190
{
190
- /* I must avoid:
191
- + the two calls be processed without an intermediate Run() loop (by using last_loop sequence number)
191
+ /* We must avoid:
192
+ + the two calls be processed without an intermediate Run() loop
193
+ (by using last_loop sequence number and checking if the foreground queue is empty)
192
194
+ deadlock by absence of Run() loop activity (by using BothEmpty() call)
193
195
*/
194
196
return !logging_ ||
195
- ( logs_.Empty () &&
196
- (last_loop != current_loop_ || logs_.BothEmpty () ));
197
+ logs_.BothEmpty () ||
198
+ (last_loop != current_loop_ && logs_.Empty ( ));
197
199
});
198
200
199
201
last_loop = current_loop_;
You can’t perform that action at this time.
0 commit comments