|
virthttp
0.0
libvirt http interface
|
#include <async_store.hpp>
Classes | |
| struct | Element |
Public Types | |
| enum | TaskStatus { TaskStatus::non_existent, TaskStatus::in_progress, TaskStatus::finished } |
| using | IndexType = std::uint32_t |
| Type used as the key to elems. More... | |
| using | ClockType = std::chrono::system_clock |
| Type used for the expiration clock. More... | |
Public Member Functions | |
| template<class Fcn > | |
| std::optional< IndexType > | launch (Fcn &&fcn, std::optional< std::chrono::seconds > expire_opt=std::nullopt) |
| std::pair< TaskStatus, std::string > | value_if_ready (IndexType id) |
| void | gc () noexcept |
Public Attributes | |
| std::mutex | mut {} |
| mutex to make elems thread-safe More... | |
| std::unordered_map< IndexType, Element > | elems |
| actual container of entries More... | |
| IndexType | last_id {-1u} |
| last allocated id; ids are incremental More... | |
| std::chrono::seconds | default_expire = 120s |
| default entry expiration time More... | |
Static Public Attributes | |
| static constexpr std::chrono::seconds | init_expire = std::chrono::seconds::max() |
| expiration since initial request until task completion More... | |
Storage for asynchronous requests
| using AsyncStore::ClockType = std::chrono::system_clock |
Type used for the expiration clock.
| using AsyncStore::IndexType = std::uint32_t |
Type used as the key to elems.
|
strong |
|
inlinenoexcept |
Discard expired entries
|
inline |
Launches a task, optionally with a specified post-completion expiration time
| Fcn | (deduced) |
| [in] | fcn | the callable to be called to obtain the response body |
| [in] | expire_opt | an optional expiration time after task completion |
std::nullopt if the store is full Note: when integrating deflate compression, add here as well
|
inline |
Get a task's status by key, and its response buffer if ready
| [in] | id | the task's key |
| std::chrono::seconds AsyncStore::default_expire = 120s |
default entry expiration time
|
static |
expiration since initial request until task completion
| IndexType AsyncStore::last_id {-1u} |
last allocated id; ids are incremental
| std::mutex AsyncStore::mut {} |
mutex to make elems thread-safe
1.8.11