title: How to prevent the NodeJS event loop from exiting?
body: <p>I've implemented a native function which takes a callback. NodeJS knows the interface, but it doesn't know anything about its implementation. This native function receives a callback and will call it when the result is ready. I don't want the event loop to exit while the callback hasn't been called.</p>
  
  <p>Here is <a href="https://github.com/madadam/rust_ffi_async_demo/blob/1e5b5b98c42f01b5acc10228a8446a747bb7f36d/js/index.js#L15" rel="noreferrer">an example of such a problem</a>.</p>
  
  <p>Currently I need to do some I/O (even if it's a dumb timeout) to force NodeJS to wait for my function.</p>
  
  <p>In <a href="http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/reference/io_service__work.html" rel="noreferrer">Boost.Asio I'd just instantiate a <code>work</code> object and destroy it when the callback is called</a>. Boost.Asio's event loop wouldn't exit while this object is kept around. Is there a similar approach for NodeJS? What do I use in NodeJS (bonus if your answer doesn't mention timers)?</p>