mirror of
https://github.com/denoland/deno.git
synced 2024-10-29 08:58:01 -04: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) {
|
||||
// TODO Use std::unique_ptr
|
||||
auto pair =
|
||||
std::make_pair(req_id, new v8::Persistent<v8::Value>(d->isolate, data_v));
|
||||
d->async_data_map.insert(pair);
|
||||
d->async_data_map.emplace(std::piecewise_construct, std::make_tuple(req_id),
|
||||
std::make_tuple(d->isolate, data_v));
|
||||
}
|
||||
|
||||
void DeleteDataRef(Deno* d, int32_t req_id) {
|
||||
// Delete persistent reference to data ArrayBuffer.
|
||||
auto it = d->async_data_map.find(req_id);
|
||||
if (it != d->async_data_map.end()) {
|
||||
auto pair = *it;
|
||||
auto p = pair.second;
|
||||
p->Reset();
|
||||
delete p;
|
||||
it->second.Reset();
|
||||
d->async_data_map.erase(it);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ struct deno_s {
|
|||
|
||||
int32_t pending_promise_events;
|
||||
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;
|
||||
int32_t next_req_id;
|
||||
void* user_data;
|
||||
|
|
Loading…
Reference in a new issue