How to: mock async call

Hi

A function I have to mock gets a callback as a parameter. In my stub I would like to return immediately but call the callback asynchronously later on (like it would be in reality as the function normally accesses a database).

What's best practice how to do that in C++?

I guess it's something like:

1
2
3
4
5
bool functionToBeMocked(CallbackObject* cb)
{
  doAsync(cb->callback()); //how to implement doAsync?? using a new thead?
  return true;
}


I'm using Google's C++ mock framework.

Thanks!
Topic archived. No new replies allowed.