Skip to content

Commit 86c28ae

Browse files
committed
Revise shutdown proceedure. Rename variables
1 parent 2cb5121 commit 86c28ae

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

opencog/persist/proxy/WriteBufferProxy.cc

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

9898
void 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
107111
barrier();
108-
_atom_queue.close();
109-
_value_queue.close();
110112

111113
WriteThruProxy::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

opencog/persist/proxy/WriteBufferProxy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ class WriteBufferProxy : public WriteThruProxy
5757
size_t _high_water_mark;
5858
concurrent_set<Handle> _atom_queue;
5959
concurrent_set<std::pair<Handle,Handle>> _value_queue;
60-
std::thread _write_thread;
60+
std::thread _drain_thread;
6161
bool _stop;
62-
void write_loop();
62+
void drain_loop();
6363
void erase_recursive(const Handle&);
6464

6565
private:

0 commit comments

Comments
 (0)