Add a Waitable class for cross-thread results

This will be used for informing the main thread about whether the
database thread could establish a connection, which we'd like to do
synchronously.