Comment #2 on issue 2906 by TruSktr: Is there some way to detect when a function's asynchronous processes have finished with traditional callbacks or events?
http://code.google.com/p/v8/issues/detail?id=2906

What I mean is this:

Suppose the function asyncFunction is defined as follows.

var asyncFunction = function() {
    setTimeout(function() {
        // do nothing
    }, 5000);
};

Notice that asyncFunction does not accept a callback as an argument and it also also does not emit any events.

Now, suppose I can only use asyncFunction and cannot modify it.

How then would I be able to execute another function (let's call it someOtherFunction, for example) after all the stuff in asyncFunction is done?

As far as I know, it's not possible. What I'm suggesting is a new function (let's call it whenAbsolutelyDone, for example) that can execute a function passed to it and (in some way still to be implemented in the mechanisms beneath JavaScript) detect when the stuff in the said function is completely done, be it synchronous or asynchronous (but obviously 100% synchronous functions are easy to deal with so the asynchronous cases are what matter here).

So, considering that asyncFunction accepts no callback function and does not emit any events, the new function would allow you to run a callback after asyncFunction finishes like in the following example.

whenAbsolutelyDone(asyncFunction, function() {
    // this function runs after everything in asyncFunction is done;
// approximately 5 seconds from the call to whenAbsolutelyDone in this example.
});

Does that make sense? I don't think a feature like this exists yet.

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" 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/groups/opt_out.

Reply via email to