Add CachingHTTPFileSource::clearLoop()
So loop state can be cleaned up in the appropriate thread. This is a hack; loop needs to be externalized from Map. Fixes #686
This commit is contained in:
@@ -13,21 +13,6 @@ CachingHTTPFileSource::CachingHTTPFileSource(const std::string &path_)
|
||||
: path(path_) {}
|
||||
|
||||
CachingHTTPFileSource::~CachingHTTPFileSource() {
|
||||
if (hasLoop()) {
|
||||
assert(thread_id == std::this_thread::get_id());
|
||||
uv_messenger_stop(queue, [](uv_messenger_t *msgr) {
|
||||
delete msgr;
|
||||
});
|
||||
|
||||
util::ptr<BaseRequest> req;
|
||||
|
||||
// Send a cancel() message to all requests that we are still holding.
|
||||
for (const std::pair<std::string, std::weak_ptr<BaseRequest>> &pair : pending) {
|
||||
if ((req = pair.second.lock())) {
|
||||
req->cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CachingHTTPFileSource::setLoop(uv_loop_t* loop_) {
|
||||
@@ -47,6 +32,26 @@ bool CachingHTTPFileSource::hasLoop() {
|
||||
return loop;
|
||||
}
|
||||
|
||||
void CachingHTTPFileSource::clearLoop() {
|
||||
assert(thread_id == std::this_thread::get_id());
|
||||
assert(loop);
|
||||
|
||||
uv_messenger_stop(queue, [](uv_messenger_t *msgr) {
|
||||
delete msgr;
|
||||
});
|
||||
|
||||
util::ptr<BaseRequest> req;
|
||||
|
||||
// Send a cancel() message to all requests that we are still holding.
|
||||
for (const std::pair<std::string, std::weak_ptr<BaseRequest>> &pair : pending) {
|
||||
if ((req = pair.second.lock())) {
|
||||
req->cancel();
|
||||
}
|
||||
}
|
||||
|
||||
store.reset();
|
||||
}
|
||||
|
||||
void CachingHTTPFileSource::setBase(const std::string &value) {
|
||||
assert(thread_id == std::this_thread::get_id());
|
||||
base = value;
|
||||
|
||||
Reference in New Issue
Block a user