[nodejs] Re: Does clearTimeout remove an unprocessed callback which is already in the execution queue?

2012-12-13 Thread Andrei Sedoi
Is this test accurate? var t1 = setTimeout(function() { clearTimeout(t2); }, 0); var t2 = setTimeout(function() { console.log("hello world"); }, 0); On Thursday, December 13, 2012 2:06:02 PM UTC+2, Andrei Sedoi wrote: > > > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https:/

Re: [nodejs] Re: Does clearTimeout remove an unprocessed callback which is already in the execution queue?

2012-12-13 Thread Ben Noordhuis
On Thu, Dec 13, 2012 at 1:24 PM, Andrei Sedoi wrote: > Is this test accurate? > > var t1 = setTimeout(function() { > clearTimeout(t2); > }, 0); > > var t2 = setTimeout(function() { > console.log("hello world"); > }, 0); No. The order in which the timer callbacks run is unspecified, same as f

Re: [nodejs] Re: Does clearTimeout remove an unprocessed callback which is already in the execution queue?

2012-12-13 Thread Andrei Sedoi
I see. The test is inaccurate. Do you have an answer to the original question? On Thursday, December 13, 2012 2:34:28 PM UTC+2, Ben Noordhuis wrote: > > On Thu, Dec 13, 2012 at 1:24 PM, Andrei Sedoi > > wrote: > > Is this test accurate? > > > > var t1 = setTimeout(function() { > > clearTim

Re: [nodejs] Re: Does clearTimeout remove an unprocessed callback which is already in the execution queue?

2012-12-13 Thread Ben Noordhuis
On Thu, Dec 13, 2012 at 1:40 PM, Andrei Sedoi wrote: > I see. The test is inaccurate. Do you have an answer to the original > question? The original question being "Does clearTimeout remove an unprocessed callback which is already in the execution queue"? It does. -- Job Board: http://jobs.nod

Re: [nodejs] Re: Does clearTimeout remove an unprocessed callback which is already in the execution queue?

2012-12-13 Thread Andrei Sedoi
Cool. Thanks! On Thursday, December 13, 2012 2:43:44 PM UTC+2, Ben Noordhuis wrote: > > On Thu, Dec 13, 2012 at 1:40 PM, Andrei Sedoi > > wrote: > > I see. The test is inaccurate. Do you have an answer to the original > > question? > > The original question being "Does clearTimeout remove an u

Re: [nodejs] Re: Does clearTimeout remove an unprocessed callback which is already in the execution queue?

2012-12-13 Thread Jorge Chamorro
On 13/12/2012, at 13:34, Ben Noordhuis wrote: > On Thu, Dec 13, 2012 at 1:24 PM, Andrei Sedoi wrote: >> Is this test accurate? >> >> var t1 = setTimeout(function() { >> clearTimeout(t2); >> }, 0); >> >> var t2 = setTimeout(function() { >> console.log("hello world"); >> }, 0); > > No. The ord

Re: [nodejs] Re: Does clearTimeout remove an unprocessed callback which is already in the execution queue?

2012-12-13 Thread Ben Noordhuis
On Thu, Dec 13, 2012 at 2:49 PM, Jorge Chamorro wrote: > On 13/12/2012, at 13:34, Ben Noordhuis wrote: >> On Thu, Dec 13, 2012 at 1:24 PM, Andrei Sedoi wrote: >>> Is this test accurate? >>> >>> var t1 = setTimeout(function() { >>> clearTimeout(t2); >>> }, 0); >>> >>> var t2 = setTimeout(function

Re: [nodejs] Re: Does clearTimeout remove an unprocessed callback which is already in the execution queue?

2012-12-13 Thread Isaac Schlueter
And, just like in browsers, node's execution order is indeterminate, but will run t1 before t2 ***BUT! that is an implementation detail you should not rely upon***. On Thu, Dec 13, 2012 at 5:54 AM, Ben Noordhuis wrote: > On Thu, Dec 13, 2012 at 2:49 PM, Jorge Chamorro > wrote: >> On 13/12/2012,

Re: [nodejs] Re: Does clearTimeout remove an unprocessed callback which is already in the execution queue?

2012-12-13 Thread Jorge Chamorro
Not-in-a-spec is !== indeterminate. All the browsers do it right, even though it's not in any w3c spec. There's many many other things in the browsers that aren't (or weren't until recently) in any spec. De-facto standard behaviours, if you will. -- Jorge. On 13/12/2012, at 22:09, Isaac Schlu