Hacker News new | ask | show | jobs
by chimeracoder 4829 days ago
Be careful of double-checked locking errors: http://en.wikipedia.org/wiki/Double-checked_locking
1 comments

seeing as this is node you won't need a lock (and since it is single threaded there are no cross thread visibility issues).

What you do need is a state variable that indicates if the connection is uninitialized, loading, or ready. And if it is in the loading state you need to have a list of callbacks so that concurrent requests can be added to the list.