'Wait for `.notify`.
Returns a `.Future` that resolves ``True`` if the condition is notified,
or ``False`` after a timeout.'

def wait(self, timeout=None):

    waiter = Future()
    self._waiters.append(waiter)
    if timeout:
        def on_timeout():
            waiter.set_result(False)
            self._garbage_collect()
        io_loop = ioloop.IOLoop.current()
        timeout_handle = io_loop.add_timeout(timeout, on_timeout)
        waiter.add_done_callback((lambda _: io_loop.remove_timeout(timeout_handle)))
    return waiter
