>
> I think what the OP means, is that library authors should wrap 
> *synchronous* callback calls in process.nextTick


…yep, I mean wrap synchronous callbacks if there's any possibility the 
function might execute asynchronously… though Tim Caswell suggests 
above<https://groups.google.com/d/msg/nodejs/yVzbK7dyCP8/1HqqyoGXPY8J> that 
this 
may not be best practice, and I am eagerly awaiting further elaboration.

-Tim


On Friday, 12 October 2012 03:40:42 UTC+10, Adam Crabtree wrote:
>
> I think what the OP means, is that library authors should wrap 
> *synchronous* callback calls in process.nextTick, which is a best practice.
>
> If you're saying (possibly) that it's not, then I disagree. 
> Library code should be predictable, not synchronous in some cases and 
> asynchronous in others. process.nextTick is not slower, it adds only the 
> minimal deprioritization necessary to execute your code asynchronously 
> (i.e. consistently). This does not undermine any cache performance as 
> nextTick executes on the order of <1ms, significantly faster than any I/O.
>
> Cheers,
> Adam Crabtree
>
> On Thu, Oct 11, 2012 at 7:51 AM, Axel Kittenberger 
> <axk...@gmail.com<javascript:>
> > wrote:
>
>> > Inconsistent sync/async
>> > When functions are sometimes sync and sometimes async lead to hard to 
>> use
>> > apis, subtle bugs and more error handling wrapper code. Always wrap
>> > callbacks in process.nextTick if they're not behind an async operation.
>> > Simple.
>>
>> As others have written, if you have to have to do this,then your async
>> handling is cranked up. Caches aren't there for nothing. If the callee
>> depends on a particular order that it is in error not you, and I'd
>> rather see errors fixed than leaving them in and not raising'em. I
>> won't say, use one of the 1000ooo.... (a)sync libraries, but if the
>> callee would use one of them (like my favorite streamline) the
>> "problem" won't be one, and that one for example will get good
>> performance using trampolining technology. This is only sanely
>> available to you if you are the application developer, if you develop
>> a library, just take care.
>>
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines: 
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to nod...@googlegroups.com<javascript:>
>> To unsubscribe from this group, send email to
>> nodejs+un...@googlegroups.com <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>
>
>
> -- 
> Better a little with righteousness 
>        than much gain with injustice.
> Proverbs 16:8
>  

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to