dca_interface
6.3.4
|
As detailed in the example programs found under samples/url_sample_extended or samples/customdbsample_extended, it is necessary to create two threads for the scheduling and update mechanisms.
The threads are usually in a loop and call the schedule() and performUpdate() functions:
Both threads must have an end condition. In this case, the class MyContext contains a variable inShutdown. This variable is set to true in the destructor of MyContext.
The MyContext destructor also calls the functions dca::UpdateModule::cancelUpdate() and dca::DcaInstance::signal() before the dca::DcaInstance objects are destroyed. The cancelUpdate() function cancels all currently active downloads and uploads, while the signal() function aborts all other long-lasting processes.
The following code sample demonstrates this:
After both functions have been successfully called, it is necessary to wait for the worker threads to end before shutting down the dca::DcaInstance objects.