Indeed, it's only possible using timers.
So, yes, you must wait 1ms.

What I can suggest is an "Event queue" also called "Reactor" (see : http://wiki.commonjs.org/wiki/Reactor/A)

For instance :

Write a function that check is there is something to call in the queue.
Call that fonction every 1ms.

When you have something async to execute, push it on the queue.

So, you can have a chance that it takes less than 1ms ;) (1ms as worse-case).

Anthony C.

D J G C a écrit :
How can I call a function with a delay of 0 seconds and non-blocking?

Non-blocking: The statement following the function call is run
immediatly and not waiting for the function to complete!

On May 22, 3:49 am, Anthony Catel <[email protected]> wrote:
What do you mean? What kind of function?

D J G C a écrit :



Yes I thought that. But how can I make a non-blocking (asynchronous)
function call?
On May 22, 3:40 am, Anthony Catel <[email protected]> wrote:
No, it's not an issue.
The minimum value for a timer is 1ms.
10000ms = 10sec
Anthony C. Nicolas Trani a écrit :
Hi,
there is an issue with Ape.setTimeout in APE 1.0 you have to update to
git version.
Cheers. On 22/05/2010 02:42, D J G C wrote:
Ape.setTimeout is extremely slow! If I call recursivly 10000 times the
same function with setTimeout it takes 10 seconds. If I call 10000 an
SQL SELECT 1 where the callback is the function itself it takes 0.9s.
is there a better way to call a function asyncrhounsly? This is the code to test it: //######################## setTimeout
var start;
test();
function test(i)
{
    if(i<10000)
        Ape.setTimeout(test,0,i+1);
    else
        Ape.log("test done in "+($time()-start)/1000+ "seconds");
};
//######################## mysql
var start;
test();
function test(i)
{
    if(i<10000)
        sql.query("SELECT 1",function(){
                test2(i+1);
        });
    else
        Ape.log("test done in "+($time()-start)/1000+ "seconds");
};
--
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group 
athttp://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website :http://www.ape-project.org/
Git Hub :http://github.com/APE-Project/
--
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group 
athttp://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website :http://www.ape-project.org/
Git Hub :http://github.com/APE-Project/


--
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/

Reply via email to