mardi 2 août 2016

How do I start a C++ thread at program startup?

I'm writing a C++ library to allow programs to talk to a service in the cloud. I want to run a background thread which periodically checks the server and restarts it in case of failure. However it would be nice for the main program outside the library not to have to worry about starting the thread. The use of library should be limited to useProcess(). By this point the thread should already be running.

How do I start a thread without the main program having to call any functions? Is there a way to do this in a static constructor of my service class so that it starts the thread at program start (as I would do in Java)?

Aucun commentaire:

Enregistrer un commentaire