[webkit-dev] Asynchronous JavaScript method support

Darin Adler darin at apple.com
Fri May 29 10:12:15 PDT 2009


On May 29, 2009, at 1:46 AM, Jack Wootton wrote:

> Does WebKit allow for asynchronous methods / functions to be added  
> to the JavaScript environment?

There’s no clear definition for “asynchronous functions” so I can’t  
really answer that question.

There are many JavaScript functions that do work and then later call a  
function to indicate the work is complete. If you’re using the  
JavaScriptCore API you can easily implement something like that. But  
you need to be sure to manipulate the JavaScript objects only on the  
same thread the JavaScript call comes in on. In the WebKit context  
that means only on the main thread.

So you can do some work, and then make a call to a JavaScript function  
that the caller passed on the main thread.

     -- Darin



More information about the webkit-dev mailing list