title: In a native node module, how can I make sure that my async code is always running on the same thread?
body: <p>I'm writing a native node module in C++ which will be a binding for a C library.</p>
  
  <p>Some of the objects in this library <strong>must only be used by a single thread</strong>. Which means that if I use <code>uv_queue_work</code> I can't make sure they are only used by the same thread, since - <em>as far as I know</em> - libuv uses a thread pool and I haven't been able to find out how to tell it what thread to use for this kind of work.</p>
  
  <p>Here are some ideas for the situation, but I'm not sure which is the correct approach.</p>
  
  <ul>
  <li>Simply make all the methods synchronous - this would unfortunately beat the purpose and concepts of node, so I'd prefer not to</li>
  <li>Create a custom thread and execute my code on that - this would defeat the purpose of libuv's thread pool and require more work</li>
  <li>Tell libuv somehow to execute operations of the same object on the same thread in its thread pool - I haven't found a way in the documentation to do this</li>
  </ul>
  
  <p>What is the recommended course of action for this kind of Node.js module?</p>