[nodejs] Transforming stream - when to call callback

2013-04-14 Thread Mike Pilsbury
I'm extending Transform, and I'm a little unclear when to call transform._transform(chunk, encoding, callback)'s callback. The documentation says "Call the callback function only when the current chunk is completely consumed. Note that there may or may not be output as a result of any particula

[nodejs] Socket.write and writable

2013-04-14 Thread Angel Java Lopez
Hi everyone! I met this issue, some months ago, with Node 0.8.x. I think the same issue could be at 0.10.x I have two opened sockets: socketin, socketout. With something like: socketin.on('data', /* process input data, transform it, and maybe, write to socketout */); socketout.on('error', /* rem

[nodejs] Re: Transforming stream - when to call callback

2013-04-14 Thread Tom Dunn
Here's what I have done in the past, if I get an incomplete chunk, I hang on to it and call done, I have technically consumed it by hanging on to it. When I get another chunk I check if that completes my partial chunk, if it does, I do this.push then call done, if I don't I hang to another part

[nodejs] Re: Transforming stream - when to call callback

2013-04-14 Thread Mike Pilsbury
> I have technically consumed it by hanging on to it. That's the bit that I was concerned about. I wasn't sure that I could rely on the Buffer's contents remaining valid until I used it. It's good to know that I can take the simple approach. Thanks. On Sunday, 14 April 2013 16:57:17 UTC+1, Tom

[nodejs] fs.watch, filename parameter

2013-04-14 Thread Gagle
>From docs: Filename Argument > > Providing filename argument in the callback is not supported on every > platform (currently it's only supported on Linux and Windows). Even on > supported platforms filename is not always guaranteed to be provided. > Therefore, don't assume that filename argume

[nodejs] Does node::Buffer free foreign set memory on garbage collection?

2013-04-14 Thread Bodo Kaiser
Hello, i want to know if a buffer which I have fed with own data is able to free this or if there is an api for manual freeing. See: https://gist.github.com/bodokaiser/5383405 Bodo -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-

[nodejs] Adding support for multiple parallel programming approaches, mixing them in the same node.js application

2013-04-14 Thread Sean Halle
Hi Node Groupies, It seems that many back-end applications could take advantage of parallel execution. For example, analysis of data, extracting business intelligence, machine learning, and so forth. The "asynchronous" style has some nice properties for implementing that kind of functiona

[nodejs] Nodeclipse 0.3 has been released

2013-04-14 Thread Tomoyuki Inagaki
Hi All, Nodeclipse 0.3 has been released Check out below, http://marketplace.eclipse.org/content/nodeclipse http://www.nodeclipse.org/ http://www.youtube.com/watch?v=8ACnLALdKT8 Enjoy! Thanks. -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Ma

[nodejs] CPU raises to 70%-90%

2013-04-14 Thread anil kumar
A Simple Hello World Program (No third paty modules included) takes 70-90% of CPU when ab -n 1000 -c 100 http://x.x.x.x:3000/ (100 concurent connections) on 2GB server . Is it default in node or need to change any setting regarding CPU usage ? Node version - 0.10.0 && 0.10.4 Server : AWS Sma

Re: [nodejs] CPU raises to 70%-90%

2013-04-14 Thread Fedor Indutny
I believe its ok, because you're doing "stress-testing". Cheers, Fedor. On Sun, Apr 14, 2013 at 8:58 AM, anil kumar wrote: > A Simple Hello World Program (No third paty modules included) takes 70-90% > of CPU when > ab -n 1000 -c 100 http://x.x.x.x:3000/ (100 concurent connections) > on 2GB se

Re: [nodejs] fs.watch, filename parameter

2013-04-14 Thread Ben Noordhuis
On Sun, Apr 14, 2013 at 6:16 PM, Gagle wrote: > From docs: > >> Filename Argument >> >> Providing filename argument in the callback is not supported on every >> platform (currently it's only supported on Linux and Windows). Even on >> supported platforms filename is not always guaranteed to be pro

Re: [nodejs] CPU raises to 70%-90%

2013-04-14 Thread Ben Noordhuis
On Sun, Apr 14, 2013 at 2:58 PM, anil kumar wrote: > A Simple Hello World Program (No third paty modules included) takes 70-90% > of CPU when > ab -n 1000 -c 100 http://x.x.x.x:3000/ (100 concurent connections) > on 2GB server . Is it default in node or need to change any setting > regarding CPU u

Re: [nodejs] Does node::Buffer free foreign set memory on garbage collection?

2013-04-14 Thread Ben Noordhuis
On Sun, Apr 14, 2013 at 6:59 PM, Bodo Kaiser wrote: > Hello, > > i want to know if a buffer which I have fed with own data is able to free > this or if there is an api for manual freeing. > > See: > https://gist.github.com/bodokaiser/5383405 > > Bodo Check src/node_buffer.h, there's a Buffer::New

[nodejs] Re: fs.watch, filename parameter

2013-04-14 Thread Gagle
But suppose that I'm already controlling that case and I'm sure that the change event it's a real file change. Can I still rely on the filename parameter? -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You recei

Re: [nodejs] Does node::Buffer free foreign set memory on garbage collection?

2013-04-14 Thread Bodo Kaiser
Thanks for the hint. So the node Buffer does not free my assigned bytes when I do not use the free_callback? Bodo Am 14.04.2013 um 20:02 schrieb Ben Noordhuis : > On Sun, Apr 14, 2013 at 6:59 PM, Bodo Kaiser wrote: >> Hello, >> >> i want to know if a buffer which I have fed with own data is

Re: [nodejs] Does node::Buffer free foreign set memory on garbage collection?

2013-04-14 Thread Nathan Rajlich
Since you're using the version of Buffer::New() where it allocates memory for you, then yes, the memory will be free'd when the Buffer is garbage collected. On Sun, Apr 14, 2013 at 11:08 AM, Bodo Kaiser wrote: > Thanks for the hint. > > So the node Buffer does not free my assigned bytes when I d

Re: [nodejs] Re: fs.watch, filename parameter

2013-04-14 Thread Ben Noordhuis
On Sun, Apr 14, 2013 at 8:08 PM, Gagle wrote: > But suppose that I'm already controlling that case and I'm sure that the > change event it's a real file change. Can I still rely on the filename > parameter? On the platforms that support that, yes. -- -- Job Board: http://jobs.nodejs.org/ Posti

Re: [nodejs] Does node::Buffer free foreign set memory on garbage collection?

2013-04-14 Thread Ben Noordhuis
On Sun, Apr 14, 2013 at 8:08 PM, Bodo Kaiser wrote: > Thanks for the hint. > > So the node Buffer does not free my assigned bytes when I do not use the > free_callback? > > Bodo The non-free_callback versions of Buffer::New() copy the memory. You're responsible for freeing the original memory.

Re: [nodejs] Does node::Buffer free foreign set memory on garbage collection?

2013-04-14 Thread Bodo Kaiser
Okay good to know thank you! Bodo Am 14.04.2013 um 20:16 schrieb Ben Noordhuis : > On Sun, Apr 14, 2013 at 8:08 PM, Bodo Kaiser wrote: >> Thanks for the hint. >> >> So the node Buffer does not free my assigned bytes when I do not use the >> free_callback? >> >> Bodo > > The non-free_callbac

Re: [nodejs] Re: correct way to read from a Readable stream

2013-04-14 Thread Jorge
On 30/03/2013, at 00:56, Isaac Schlueter wrote: > ```javascript > var chunk; > while (null !== (chunk = rs.read())) { > doSomething(chunk); > } > ``` I use to write code like that too but it might break it seems, look: this works: function work

Re: [nodejs] Re: Transforming stream - when to call callback

2013-04-14 Thread Isaac Schlueter
Call the callback when you're ready to get more chunks. If that means "I've stashed this, but I need to see more before I can do anything," then that's fine. You don't have to stash the callback anywhere. It's the same function each time :) On Sun, Apr 14, 2013 at 9:03 AM, Mike Pilsbury wrote

Re: [nodejs] Re: Transforming stream - when to call callback

2013-04-14 Thread Mike Pilsbury
Thanks, it's good to have that confirmed. On Sunday, 14 April 2013 23:51:19 UTC+1, Isaac Schlueter wrote: > > Call the callback when you're ready to get more chunks. > > If that means "I've stashed this, but I need to see more before I can > do anything," then that's fine. > > You don't have to