I'm fairly new to advanced C++ program techniques such as templates, but I am developing a simple API for a project I'm working on.
The function or method that you call can take a long time to complete. Essentially it's transferring a file over the network.
It looks a bit like this.
Client
{
int WriteFile();
int ReadFile();
}
But I want to have a couple of options here.
- call WriteFile and have it block.
- Call WriteFileAsync and not have it block.
- In the async version be flexible about how I know the task is done.
- Be able to poll the client to find out where it's up to with my current Read or Write operation.
I'm at a bit of a loss as to how to design this nicely the C++ way. It's a requirement to avoid using boost, but I could use a boost-like approach. Although, I looked through some of the headers and got very much confused. Anything beyond basic template programming for me I find confusing.
What I'm after is a nice way of being notified of event completion and be able to wait for an event to complete.