OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-cogutil commits / 44fedd2

Bug-fix: reset the barrier phase when stopping
44fedd2ab4f25290582c9c2ff889d051a4d9d764
by Linas Vepstas <linasvepstas@gmail.com> · 2025-12-07T00:57:04.000Z

Changed files (2) +8 -14

opencog/util/async_buffer.h +4 -7
……@@ -365,7 +365,10 @@ void async_buffer<Writer, Element>::stop_writer_threads()
365365 Element elt = _store_set.value_get();
366366 (_writer->*_do_write)(elt);
367367 }
368
368
369 _barrier_phase = 0;
370 _barrier_remaining = 0;
371
369372 // Its now OK to start new threads, if desired ...(!)
370373 _stopping_writers = false;
371374}
……@@ -385,10 +388,7 @@ void async_buffer<Writer, Element>::drain()
385388 // XXX TODO - when C++20 becomes widely available,
386389 // replace this loop by _pending.wait(0)
387390 while (0 < _pending)
388 {
389391 std::this_thread::sleep_for(std::chrono::milliseconds(1));
390 // usleep(1000);
391 }
392392
393393 _stall_writers = save_stall;
394394}
……@@ -408,10 +408,7 @@ void async_buffer<Writer, Element>::flush()
408408 _flush_count++;
409409
410410 while (0 < _store_set.size())
411 {
412411 std::this_thread::sleep_for(std::chrono::milliseconds(1));
413 // usleep(1000);
414 }
415412
416413 _stall_writers = save_stall;
417414}
opencog/util/async_method_caller.h +4 -7
……@@ -284,7 +284,10 @@ void async_caller<Writer, Element>::stop_writer_threads()
284284 Element elt = _store_queue.value_pop();
285285 (_writer->*_do_write)(elt);
286286 }
287
287
288 _barrier_phase = 0;
289 _barrier_remaining = 0;
290
288291 // Its now OK to start new threads, if desired ...(!)
289292 _stopping_writers = false;
290293}
……@@ -302,10 +305,7 @@ void async_caller<Writer, Element>::drain()
302305 // XXX TODO - when C++20 becomes widely available,
303306 // replace this loop by _pending.wait(0)
304307 while (0 < _pending)
305 {
306308 std::this_thread::sleep_for(std::chrono::milliseconds(1));
307 // usleep(1000);
308 }
309309}
310310
311311
……@@ -321,10 +321,7 @@ void async_caller<Writer, Element>::flush_queue()
321321{
322322 _flush_count++;
323323 while (0 < _store_queue.size())
324 {
325324 std::this_thread::sleep_for(std::chrono::milliseconds(1));
326 // usleep(1000);
327 }
328325}
329326
330327/// Drain the pending queue. Synchronizing.