async: Implemented async with flushing thread.

* Have a single extra thread which flushes the queue on an event or
  every n seconds.

Signed-off-by: Joe MacMahon <joe.macmahon@cern.ch>