blob: 6cb882101d99393a66dd9f3f55718cb0ce1152d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <mbgl/storage/file_request.hpp>
#include <mbgl/storage/file_request_baton.hpp>
#include <mbgl/storage/response.hpp>
#include <uv.h>
#include <cassert>
#include <unistd.h>
namespace mbgl {
FileRequest::FileRequest(const std::string &path_, uv_loop_t *loop)
: BaseRequest(path_), ptr(new FileRequestBaton(this, path, loop)) {
}
void FileRequest::cancel() {
assert(std::this_thread::get_id() == threadId);
if (ptr) {
ptr->cancel();
// When deleting a FileRequest object with a uv_fs_* call is in progress, we are making sure
// that the callback doesn't accidentally reference this object again.
ptr->request = nullptr;
ptr = nullptr;
}
notify();
}
FileRequest::~FileRequest() {
assert(std::this_thread::get_id() == threadId);
cancel();
}
}
|