Skip to content

Commit

Permalink
fixup! src: use RAII to manage the main isolate data
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung committed Apr 16, 2019
1 parent dc8cde7 commit 51eb301
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/node_main_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ NodeMainInstance::NodeMainInstance(uv_loop_t* event_loop,
const std::vector<std::string>& exec_args)
: args_(args),
exec_args_(exec_args),
array_buffer_allocator_(CreateArrayBufferAllocator()),
array_buffer_allocator_(ArrayBufferAllocator::Create()),
isolate_(nullptr),
isolate_data_(nullptr) {
// TODO(joyeecheung): when we implement snapshot integration this needs to
Expand Down
11 changes: 5 additions & 6 deletions src/node_main_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class NodeMainInstance {
NodeMainInstance(NodeMainInstance&&) = delete;
NodeMainInstance& operator=(NodeMainInstance&&) = delete;

explicit NodeMainInstance(uv_loop_t* event_loop,
const std::vector<std::string>& args,
const std::vector<std::string>& exec_args);
NodeMainInstance(uv_loop_t* event_loop,
const std::vector<std::string>& args,
const std::vector<std::string>& exec_args);
~NodeMainInstance();

// Start running the Node.js instances, return the exit code when finished.
Expand All @@ -34,10 +34,9 @@ class NodeMainInstance {

std::vector<std::string> args_;
std::vector<std::string> exec_args_;
DeleteFnPtr<ArrayBufferAllocator, FreeArrayBufferAllocator>
array_buffer_allocator_;
std::unique_ptr<ArrayBufferAllocator> array_buffer_allocator_;
v8::Isolate* isolate_;
DeleteFnPtr<IsolateData, FreeIsolateData> isolate_data_;
std::unique_ptr<IsolateData> isolate_data_;
};

} // namespace node
Expand Down

0 comments on commit 51eb301

Please sign in to comment.