I would like to implement an object that queries a database and executes a query asynchronously.
Suppose we have an object A to query uses the object B. A calls executeQuery method of B and starts to do anything else. ExecuteQuery method of B is asynchronous, non-blocking for quini A. When the result of the query is ready I wish it was notified in B to A with a callback so that A can go and read the result only when ready.
What is the best way to implement this mechanism in C ++ 11?
I tried it with std :: async but instead to read the result in std :: future I would like to receive a callback when my std :: future already contains the result thus avoiding my call becomes a blocker.
Thank You