#include <restincurl.h>

Public Member Functions | |
| Client (const bool init=true) | |
| virtual | ~Client () |
| std::unique_ptr< RequestBuilder > | Build () |
| void | CloseWhenFinished () |
| void | Close () |
| void | WaitForFinish () |
| bool | HaveWorker () const |
| size_t | GetNumActiveRequests () |
The high level abstraction of the Curl library.
An instance of a Client will, if asynchronous mode is enabled, create a worker-thread when the first request is made. This single worker-thread is then shared between all requests made for this client. When no requests are active, the thread will wait for a while (see RESTINCURL_IDLE_TIMEOUT_SEC), keeping libcurl's connection-cache warm, to serve new requests as efficiently as possible. When the idle time period expires, the thread will terminate and close the connection-cache associated with the client. If a new request is made later on, a new worker-thread will be created.
|
inline |
Constructor
| init | Set to true if you need to initialize libcurl. |
Libcurl require us to call an initialization method once, before using the library. If you use libcurl exclusively from RESTinCurl, init needs to be true (default). If you use RESTinCurl in a project that already initialize libcurl, you should pass false to the constructor.
RESTinCurl will only call libcurl's initialization once, no matter how many times you call the constructor. It's therefore safe to always use the default value when you want RESTinCurl to deal with libcurl's initialization.
References RESTINCURL_LOG.
|
inlinevirtual |
Destructor
The destructor will try to clean up resources (when in asynchronous mode) ant may wait for a little while for IO operations to stop and the worker-thread to finish.
This is to prevent your application for crashing if you exit the main thread while the worker-thread is still working and accessing memory own by the Client instance.
References RESTINCURL_LOG.
|
inline |
Build a request
Requests are "built" using a series of statements to fully express what you want to do and how you want RESTinCurl to do it.
Example
References RESTINCURL_ENABLE_ASYNC.
|
inline |
Close the client.
This method aborts any and all requests.
The worked-thread will exit shortly after this method is called, if it was running.
This method is only available when RESTINCURL_ENABLE_ASYNC is nonzero.
|
inline |
Shut down the event-loop and clean up internal resources when all active and queued requests are done.
This method is only available when RESTINCURL_ENABLE_ASYNC is nonzero.
|
inline |
Get the number of active / ongoing requests.
This method is only available when RESTINCURL_ENABLE_ASYNC is nonzero.
|
inline |
Check if the client instance has a worker-thread.
This method is only available when RESTINCURL_ENABLE_ASYNC is nonzero.
|
inline |
Wait for the worker-thread to finish.
You should call Close() first.
This method is only available when RESTINCURL_ENABLE_ASYNC is nonzero.