make sure all of our async handles are stopped before stopping the map thread

This commit is contained in:
Konstantin Käfer
2014-09-16 14:48:46 +02:00
parent d9fc7708a2
commit 6c526e5637
10 changed files with 92 additions and 56 deletions

View File

@@ -13,6 +13,7 @@ FileSource::FileSource(uv_loop_t *loop_)
store(std::shared_ptr<SQLiteStore>(new SQLiteStore(loop_, "cache.db"))),
loop(loop_),
queue(new uv_messenger_t) {
uv_messenger_init(loop, queue, [](void *ptr) {
std::unique_ptr<std::function<void()>> fn { reinterpret_cast<std::function<void()> *>(ptr) };
(*fn)();
@@ -22,6 +23,8 @@ FileSource::FileSource(uv_loop_t *loop_)
FileSource::~FileSource() {
assert(thread_id == uv_thread_self());
uv_messenger_stop(queue);
// NOTE: We don't need to delete the messenger since it will be deleted by the
// uv_messenger_stop() function.
}
void FileSource::setBase(const std::string &value) {