Singleton class to initialize and cleanup the global state of libcurl. More...
#include <libcurl.hpp>
Public Types | |
using | UniqueHandlePtr = std::unique_ptr< CURL, std::function< decltype(curl_easy_cleanup)> > |
Public Member Functions | |
UniqueHandlePtr | get_free_handle () |
Returns a free curl handle if available. | |
UniqueHandlePtr | get_handle () |
Returns a curl handle, create a new handle if none is available. | |
void | retain_handle (UniqueHandlePtr handle) |
Retain a curl handle for later use. | |
Static Public Member Functions | |
static LibCurl & | instance () |
Singleton class to initialize and cleanup the global state of libcurl.
Notice, libcurl allows the use of a singleton class:
In a C++ module, it is common to deal with the global constant situation by defining a special class that represents the global constant environment of the module. A program always has exactly one object of the class, in static storage. That way, the program automatically calls the constructor of the object as the program starts up and the destructor as it terminates. As the author of this libcurl-using module, you can make the constructor call curl_global_init and the destructor call curl_global_cleanup and satisfy libcurl's requirements without your user having to think about it. (Caveat: If you are initializing libcurl from a Windows DLL you should not initialize it from DllMain or a static initializer because Windows holds the loader lock during that time and it could cause a deadlock.)
Source https://curl.se/libcurl/c/libcurl.html.
Definition at line 50 of file libcurl.hpp.