On Thu, Dec 14, 2017 at 10:17 PM, J Decker <[email protected]> wrote:

>
> I have this process that wants to take the result of a callback and then
> pass that as the object for the next callback invokation...
>
> (truncated; argc is missing for instance; mostly I'm just intested in
> result, and the arg back in )
>
> void f( uintptr_t psv )
> {
> Local<Value> *argv = new Local<Value>[argc+1];
>
> Local<Object> recv = ((Value*)psv)->ToObject();
>
> Local<Function> cb = rule->handler.Get( config->isolate );
> Local<Value> result = cb->Call( recv, argc, argv );
> // figured I can get the result this way, and keep it ?
> uintptr_t objResult = (uintptr_t)*result;
> result.Clear();
> return objResult; // this gets passed to next f(psv)
> }
>
>
> on the javascript side the callback might be something like
>
> config.add( "format %d", function( arg ) {
>    this.format_arg = arg;
>    return this;
> }
>
> so any time the string "format ###" is found, the callback is triggered
> with ### formatted as an integer argument (for instance )
>
>
> most usages the callbacks will all be performed before returning back to
> the orignal javascript caller, but, it can be that the javascript is adding
> streaming data to the text processor iteritively so there may be a long
> time between one call to f() and the next... would the 'result' be subject
> to garbage collection when it's not in a Local<> or Persistent<>  ?
>

I would have a very last handler....

static uintptr_t CPROC releaseArg( uintptr_t lastArg ) {
Local<Object> deleteMe = ( (Value*)lastArg )->ToObject();
return 0;
}

which should release it when the stream is done.... so it shouldn't leak if
it's not collected...

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to