|
REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
|
This thread's DFA set for one regex, for the lifetime of the lease: a scan through it takes no lock, so threads sharing a regex do not queue on its DFAs. More...
#include <onepass.hpp>
Classes | |
| struct | cache |
| The set a thread keeps between leases, and the slot it returns to. More... | |
Public Member Functions | |
| dfa_lease (regex_immutables *immut) | |
Leases a DFA set for immut, cleared if it was built for an earlier program. | |
| dfa_lease (const dfa_lease &)=delete | |
| dfa_lease & | operator= (const dfa_lease &)=delete |
| dfa_lease (dfa_lease &&)=delete | |
| dfa_lease & | operator= (dfa_lease &&)=delete |
| ~dfa_lease () | |
| Ends the lease: the cached set stays with this thread, a nested one goes back to its pool. | |
| shared_dfa_set & | operator* () const noexcept |
| The leased set. | |
| shared_dfa_set * | operator-> () const noexcept |
| The leased set's members. | |
Static Public Member Functions | |
| static void | drop_thread_set (const shared_dfa_slot &slot) noexcept |
Frees this thread's cached set if it came from slot and no lease holds it: the slot's regex is gone, so no lease will ask for it again. | |
Static Private Member Functions | |
| static cache & | thread_cache () |
| This thread's cache. | |
| static std::shared_ptr< shared_dfa_slot > | slot_for (regex_immutables *immut) |
The slot for immut, created on first use (a shared reference: it may be retired). | |
| static std::unique_ptr< shared_dfa_set > | take (shared_dfa_slot &slot) |
A free set from slot's pool, or a new one. | |
| static void | give (shared_dfa_slot &slot, std::unique_ptr< shared_dfa_set > set) noexcept |
Returns set to slot's pool, or frees it when the pool cannot take it. | |
Private Attributes | |
| shared_dfa_slot * | slot_ {nullptr} |
| The slot the set belongs to. | |
| shared_dfa_set * | set_ {nullptr} |
| The leased set. | |
| bool | cached_ {false} |
| The set is this thread's cached one. | |
| std::shared_ptr< shared_dfa_slot > | nested_slot_ |
| The slot of a nested lease. | |
| std::unique_ptr< shared_dfa_set > | nested_set_ |
| The set of a nested lease. | |
This thread's DFA set for one regex, for the lifetime of the lease: a scan through it takes no lock, so threads sharing a regex do not queue on its DFAs.
Each thread keeps the set it last used, with its slot, and gives it back to that slot's pool when it moves to another regex or exits; a repeat lease is an owner check and a generation check. A nested lease (a scan started inside another scan) takes a separate set from the pool and returns it on destruction, so the outer scan's set is never handed away under it.
|
inlineexplicit |
Leases a DFA set for immut, cleared if it was built for an earlier program.
| [in] | immut | The regex whose DFAs are wanted. |
|
inlinestaticnoexcept |
Frees this thread's cached set if it came from slot and no lease holds it: the slot's regex is gone, so no lease will ask for it again.
| [in] | slot | The retired slot. |
|
inlinestaticprivatenoexcept |
Returns set to slot's pool, or frees it when the pool cannot take it.
Called from destructors, so it cannot throw: a lock that fails or a pool that cannot grow leaves set to be freed here instead of pooled, which costs the next lease a rebuild and nothing else.
| [in,out] | slot | The slot the set belongs to. |
| [in] | set | The set given back. |
|
inlinenoexcept |
The leased set.
|
inlinenoexcept |
The leased set's members.
|
inlinestaticprivate |
The slot for immut, created on first use (a shared reference: it may be retired).
| [in] | immut | The regex whose slot is wanted. |
|
inlinestaticprivate |
A free set from slot's pool, or a new one.
| [in,out] | slot | The slot whose pool is drawn from. |
|
inlinestaticprivate |
This thread's cache.