![]() |
Kurlyk
|
RAII handle that owns a registered HTTP rate-limit ID. More...
#include <HttpRateLimitHandle.hpp>
Public Member Functions | |
| HttpRateLimitHandle (const HttpRateLimitHandle &)=delete | |
| HttpRateLimitHandle & | operator= (const HttpRateLimitHandle &)=delete |
| ~HttpRateLimitHandle () | |
| Destroys the handle and releases the owned rate-limit entry. | |
| long | id () const |
| Returns immutable rate-limit ID associated with this handle. | |
| operator bool () const | |
| Checks whether the handle still owns a valid rate-limit ID. | |
Private Types | |
| using | remove_fn_t = std::function<void(long)> |
Private Member Functions | |
| HttpRateLimitHandle (long id, remove_fn_t remove_fn) | |
| Creates a handle for a registered rate-limit ID. | |
| void | reset () |
| Releases the owned rate-limit entry once. | |
Private Attributes | |
| long | m_id = 0 |
| Owned rate-limit ID, or 0 after reset. | |
| remove_fn_t | m_remove_fn |
| Callback that physically removes the rate-limit entry. | |
Friends | |
| class | HttpRateLimiter |
RAII handle that owns a registered HTTP rate-limit ID.
This object is intended to be stored through HttpRateLimitHandlePtr. Each copied std::shared_ptr keeps the corresponding rate-limit entry alive.
When the last shared handle is destroyed, the handle invokes the stored removal callback and physically removes the rate-limit entry from the owning rate limiter.
Definition at line 22 of file HttpRateLimitHandle.hpp.
|
private |
Definition at line 47 of file HttpRateLimitHandle.hpp.
|
delete |
|
inline |
Destroys the handle and releases the owned rate-limit entry.
Definition at line 28 of file HttpRateLimitHandle.hpp.
|
inlineprivate |
Creates a handle for a registered rate-limit ID.
| id | Registered rate-limit ID. |
| remove_fn | Callback used to physically remove the rate-limit entry. |
Definition at line 52 of file HttpRateLimitHandle.hpp.
|
inline |
Returns immutable rate-limit ID associated with this handle.
Definition at line 34 of file HttpRateLimitHandle.hpp.
|
inlineexplicit |
Checks whether the handle still owns a valid rate-limit ID.
Definition at line 40 of file HttpRateLimitHandle.hpp.
|
delete |
|
inlineprivate |
Releases the owned rate-limit entry once.
The ID is cleared before invoking the removal callback to prevent repeated removal if reset() is ever called more than once.
Definition at line 60 of file HttpRateLimitHandle.hpp.
|
friend |
Definition at line 45 of file HttpRateLimitHandle.hpp.
|
private |
Owned rate-limit ID, or 0 after reset.
Definition at line 70 of file HttpRateLimitHandle.hpp.
|
private |
Callback that physically removes the rate-limit entry.
Definition at line 71 of file HttpRateLimitHandle.hpp.