1 #ifndef __curl_cpp_curl_share_HPP__
2 # define __curl_cpp_curl_share_HPP__
5 # include "utils/shared_mutex.hpp"
6 # include "return-exception/ret-exception.hpp"
8 # include <curl/curl.h>
23 curl_t::Share_t curl_share;
73 none = CURL_LOCK_DATA_NONE,
74 cookie = CURL_LOCK_DATA_COOKIE,
84 dns = CURL_LOCK_DATA_DNS,
115 psl = CURL_LOCK_DATA_PSL,
126 using lock_function_t =
void (*)(CURL *handle, curl_lock_data data, curl_lock_access access,
void *userptr);
135 using unlock_function_t =
void (*)(CURL *handle, curl_lock_data data,
void *userptr);
140 void add_lock(lock_function_t lock_func, unlock_function_t unlock_func,
void *userptr)
noexcept;
175 static constexpr const std::size_t mutex_num = 5;
177 Shared_mutex_t mutexes[mutex_num];
179 auto get_mutex(
Options option)
noexcept -> Shared_mutex_t*
209 void enable_multithreaded_share()
noexcept
211 add_lock([](CURL *handle, curl_lock_data data, curl_lock_access access,
void *userptr)
noexcept {
212 auto &share = *
static_cast<Share*>(userptr);
218 if (access == CURL_LOCK_ACCESS_SHARED)
219 mutex->lock_shared();
222 }
, [](CURL *handle, curl_lock_data data,
void *userptr)
noexcept {
223 auto &share = *
static_cast<Share*>(userptr);
230 void disable_multithreaded_share()
noexcept
249 constexpr void enable_multithreaded_share()
const noexcept {}
250 constexpr void disable_multithreaded_share()
const noexcept {}