#include <CurlMultiHandleWrapper.h>
This class wraps a libcurl
multi
handle
as a C++ object. Wrapping enables:
- tracking handles to ensure that all handles are removed before curl_multi_cleanup() is called.
- centralized and consistent logging when curl_multi operations fail.
- simplified signatures for calling code.
- (slightly) improved type safety (so far just time values).
◆ ~CurlMultiHandleWrapper()
alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::~CurlMultiHandleWrapper |
( |
| ) |
|
◆ addHandle()
CURLMcode alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::addHandle |
( |
CURL * |
handle | ) |
|
Add a libcurl
handle
to this instance.
- Parameters
-
handle | The libcurl handle to add to this instance. |
- Returns
libcurl
code indicating the result of this operation.
◆ create()
static std::unique_ptr<CurlMultiHandleWrapper> alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::create |
( |
| ) |
|
|
static |
◆ getCurlHandle()
CURLM* alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::getCurlHandle |
( |
| ) |
|
Get the libcurl
multi
handle
underlying this instance.
- Returns
- The
libcurl
multi
handle
underlying this instance.
◆ infoRead()
CURLMsg* alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::infoRead |
( |
int * |
messagesInQueue | ) |
|
Receive the next messages about the libcurl
handles
added to this libcurl
multi
handle
.
- Parameters
-
[out] | messagesInQueue | The number of libcurl handles for which messages remain. |
- Returns
- The next message or nullptr if there are no more messages.
◆ perform()
CURLMcode alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::perform |
( |
int * |
runningHandles | ) |
|
Read and/or write available data for the libcurl
handles
added to this libcurl
multi
handle
.
- Parameters
-
[out] | runningHandles | Returns the number of handles for which read/write operations were performed. |
- Returns
libcurl
code indicating the result of this operation.
◆ poll()
CURLMcode alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::poll |
( |
std::chrono::milliseconds |
timeout, |
|
|
int * |
countHandlesUpdated |
|
) |
| |
Poll for actions to perform on the libcurl
handles
added to this libcurl
multi
handle
. This can waken up by the wakeup()
call.
- Note
- For Libcurl v7.68.0 or higher, this function will call curl_multi_poll(), this allows the polling thread to be woken up by the
wakeup()
call. Otherwise for Libcurl v7.67.0 or lower, it will call curl_multi_wait() and the call to wakeup()
will do nothing.
- Parameters
-
| timeout | How long to wait for actions to perform. |
[out] | countHandlesUpdated | The number of handles for which actions are ready to be performed. |
- Returns
libcurl
code indicating the result of this operation.
◆ removeHandle()
CURLMcode alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::removeHandle |
( |
CURL * |
handle | ) |
|
Remove a libcurl
handle
from this instance.
- Parameters
-
handle | The libcurl handle to remove from this instance. |
- Returns
libcurl
code indicating the result of this operation.
◆ wakeup()
bool alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::wakeup |
( |
| ) |
|
This function can be called from any thread to wake up a sleeping poll()
.
- Note
- For Libcurl v7.68.0 or higher, this function will call curl_multi_wakeup(). Otherwise, this is a no-op operation.
- Returns
true
if the call succeeded, or false
otherwise.
The documentation for this class was generated from the following file:
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0