@@ -92,21 +92,23 @@ void WriteBufferProxy::open(void)
9292
9393// Start the writer.
9494_stop = false ;
95- _write_thread = std::thread (&WriteBufferProxy::write_loop , this );
95+ _drain_thread = std::thread (&WriteBufferProxy::drain_loop , this );
9696}
9797
9898void WriteBufferProxy::close (void )
9999{
100- // Stop writing. The thread may be sleeping, so the join() might
101- // hang for a fraction of _decay seconds. It does not seem worthwhile
102- // to try to speed this up, e.g. with a condition variable.
100+ // Close. Threads that are still writing will catch an exception.
101+ _atom_queue.close ();
102+ _value_queue.close ();
103+
104+ // Stop draining. The drain thread may be sleeping, so the join()
105+ // might hang for a fraction of _ticker seconds. It does not seem
106+ // worthwhile to try to speed this up, e.g. with a condition variable.
103107_stop = true ;
104- _write_thread .join ();
108+ _drain_thread .join ();
105109
106110// Drain the queues
107111barrier ();
108- _atom_queue.close ();
109- _value_queue.close ();
110112
111113WriteThruProxy::close ();
112114}
@@ -279,7 +281,7 @@ std::string WriteBufferProxy::monitor(void)
279281// lock contention in the target. But I don't know for sure. Indirect
280282// evidence from RocksStorage indicates that bombarding it from multiple
281283// threads does not improve throughput. So, for now, just one thread.
282- void WriteBufferProxy::write_loop (void )
284+ void WriteBufferProxy::drain_loop (void )
283285{
284286// Keep a moving average queue size. This is used to determine
285287// when the queue is almost empty, by historical standards, which
0 commit comments