Contexts, scopes, mutexs and threading

21 views
Skip to first unread message

weepy

unread,
Dec 5, 2009, 9:17:03 AM12/5/09
to nodejs
Hi

Given multiple inbound requests, how is threading and scopes handled ?

E.g. I'm writing a server that validates input.

function myfunc(state, move) {
var x = 1

// various processing that will change x to another value.

return x
}

If there are multiple inbound requests, that call myfunc, are there
every more than one threads simultaneously within the function? If so,
in each thread is the variable x pointing to the same memory address
(in which case, the threads would interfere with each other). How
should one best avoid this ?

Bit confused here, so any help much appreciated.

Jonah

Ryan Dahl

unread,
Dec 5, 2009, 9:21:17 AM12/5/09
to nod...@googlegroups.com
On Sat, Dec 5, 2009 at 3:17 PM, weepy <jona...@gmail.com> wrote:
> Hi
>
> Given multiple inbound requests, how is threading and scopes handled ?
>
> E.g. I'm writing a server that validates input.
>
> function myfunc(state, move) {
>  var x = 1
>
>  // various processing that will change x to another value.
>
>  return x
> }
>
> If there are multiple inbound requests, that call myfunc, are there
> every more than one threads simultaneously within the function?

No, never. Only one thing happens at a time.

Elijah Insua

unread,
Dec 5, 2009, 2:45:45 PM12/5/09
to nod...@googlegroups.com
> If there are multiple inbound requests, that call myfunc, are there
> every more than one threads simultaneously within the function?

No, never. Only one thing happens at a time.

Thanks Ryan, This answers a question Avi and I were discussing earlier this week!
Reply all
Reply to author
Forward
0 new messages