Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Unified Diff: samples/process.cc

Issue 5302004: Fix the process sample to actually dispose the contexts used for (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/process.cc
===================================================================
--- samples/process.cc (revision 5878)
+++ samples/process.cc (working copy)
@@ -152,18 +152,16 @@
Handle<ObjectTemplate> global = ObjectTemplate::New();
global->Set(String::New("log"), FunctionTemplate::New(LogCallback));
- // Each processor gets its own context so different processors
- // don't affect each other (ignore the first three lines).
- Handle<Context> context = Context::New(NULL, global);
+ // Each processor gets its own context so different processors don't
+ // affect each other (ignore the first three lines). Context::New
+ // returns a persistent handle which is what we need for the
Rico 2010/11/24 09:18:43 what does "ignore the first three lines" mean here
Mads Ager (chromium) 2010/11/24 09:20:19 Good point. I honestly don't know. I'll remove the
+ // reference to remain after we return from this method. That
+ // persistent handle has to be disposed in the destructor.
+ context_ = Context::New(NULL, global);
- // Store the context in the processor object in a persistent handle,
- // since we want the reference to remain after we return from this
- // method.
- context_ = Persistent<Context>::New(context);
-
// Enter the new context so all the following operations take place
// within it.
- Context::Scope context_scope(context);
+ Context::Scope context_scope(context_);
// Make the options mapping available within the context
if (!InstallMaps(opts, output))
@@ -176,7 +174,7 @@
// The script compiled and ran correctly. Now we fetch out the
// Process function from the global object.
Handle<String> process_name = String::New("Process");
- Handle<Value> process_val = context->Global()->Get(process_name);
+ Handle<Value> process_val = context_->Global()->Get(process_name);
// If there is no Process function, or if it is not a function,
// bail out
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698