mirror of
https://github.com/denoland/deno.git
synced 2025-01-18 11:53:59 -05:00
libdeno: store v8::Persistent in map by value instead of by reference
This commit is contained in:
parent
d0b859ec37
commit
142e532910
2 changed files with 4 additions and 9 deletions
|
@ -21,20 +21,15 @@ Deno* FromIsolate(v8::Isolate* isolate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddDataRef(Deno* d, int32_t req_id, v8::Local<v8::Value> data_v) {
|
void AddDataRef(Deno* d, int32_t req_id, v8::Local<v8::Value> data_v) {
|
||||||
// TODO Use std::unique_ptr
|
d->async_data_map.emplace(std::piecewise_construct, std::make_tuple(req_id),
|
||||||
auto pair =
|
std::make_tuple(d->isolate, data_v));
|
||||||
std::make_pair(req_id, new v8::Persistent<v8::Value>(d->isolate, data_v));
|
|
||||||
d->async_data_map.insert(pair);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteDataRef(Deno* d, int32_t req_id) {
|
void DeleteDataRef(Deno* d, int32_t req_id) {
|
||||||
// Delete persistent reference to data ArrayBuffer.
|
// Delete persistent reference to data ArrayBuffer.
|
||||||
auto it = d->async_data_map.find(req_id);
|
auto it = d->async_data_map.find(req_id);
|
||||||
if (it != d->async_data_map.end()) {
|
if (it != d->async_data_map.end()) {
|
||||||
auto pair = *it;
|
it->second.Reset();
|
||||||
auto p = pair.second;
|
|
||||||
p->Reset();
|
|
||||||
delete p;
|
|
||||||
d->async_data_map.erase(it);
|
d->async_data_map.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ struct deno_s {
|
||||||
|
|
||||||
int32_t pending_promise_events;
|
int32_t pending_promise_events;
|
||||||
v8::Persistent<v8::Context> context;
|
v8::Persistent<v8::Context> context;
|
||||||
std::map<int32_t, v8::Persistent<v8::Value>*> async_data_map;
|
std::map<int32_t, v8::Persistent<v8::Value>> async_data_map;
|
||||||
deno_recv_cb cb;
|
deno_recv_cb cb;
|
||||||
int32_t next_req_id;
|
int32_t next_req_id;
|
||||||
void* user_data;
|
void* user_data;
|
||||||
|
|
Loading…
Add table
Reference in a new issue