On Aug 8, 2013, at 1:03 AM, aman saggar <[email protected]> wrote:
> 1)How is the state is being maintained here? > > a. If this is single threaded model, then the with the second request > coming, it wouldn’t have idea of the initial request or state > > i. If it > actually dumps the information to memory and then works on, and once it > receives event , loads state from memory > > > I. Then how it is different from multi-threading, which forking > and joining. > You're passing a function into http.createServer(); that function is invoked for every request and has its own scope. Each time that function is called it gets its own stack (local variables, etc.). Arguments passed into the function are local variables. The variables aren't shared between invocations of the function; there's no shared state and JavaScript's single-threaded model means your code is never interrupted, so you don't need to worry about managing concurrent access to those (or any other) variables. As for "who is running those non-blocking items?": the operating system. OS primitives like select() and epoll() (?) are used by Node to determine when data is available to be read or written to a file descriptor. (All IO can basically be generalized to file descriptor operations.) IO is the only non-blocking operation in JavaScript, unless you're explicitly putting a callback onto the event loop with setTimeout or setImmediate. -- Brian Lalor [email protected] http://github.com/blalor -- -- 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
