|
HikoGUI
A low latency retained GUI
|
#include <hikogui/rcu.hpp>
Public Types | |
| using | value_type = T |
| using | allocator_type = Allocator |
Public Member Functions | |
| constexpr | rcu (allocator_type allocator=allocator_type{}) noexcept |
| Construct a new rcu object. | |
| rcu (rcu const &)=delete | |
| rcu (rcu &&)=delete | |
| rcu & | operator= (rcu const &)=delete |
| rcu & | operator= (rcu &&)=delete |
| void | lock () const noexcept |
| Lock the rcu pointer for reading. | |
| void | unlock () const noexcept |
| Unlock the rcu pointer for reading. | |
| value_type const * | get () const noexcept |
| get the rcu-pointer. | |
| value_type const * | unsafe_get () noexcept |
| get the rcu-pointer. | |
| uint64_t | version () const noexcept |
| The version of the lock. | |
| size_t | capacity () const noexcept |
| Number of objects that are currently allocated. | |
| value_type * | exchange (value_type *ptr) noexcept |
| Exchange the rcu-pointers. | |
| value_type * | copy (value_type const *ptr) const noexcept |
| Create a copy of the value at the given pointer. | |
| value_type * | copy () const noexcept |
| Create a copy of the value. | |
| void | abort (value_type *ptr) const noexcept |
| Abort a copy. | |
| void | commit (value_type *ptr) noexcept |
| Commit the copied value. | |
| void | emplace (auto &&...args) noexcept |
| Emplace a new value. | |
| bool | empty () const noexcept |
| operator bool () const noexcept | |
| void | reset () noexcept |
| rcu & | operator= (nullptr_t) noexcept |
| void | add_old_copy (uint64_t old_version, value_type *old_ptr) noexcept |
| Add an old copy. | |
Read-copy-update.
| T | The type managed by RCU. |
| Allocator | The allocator used to allocate objects of type T. |
|
inlineconstexprnoexcept |
Construct a new rcu object.
| allocator | The allocator to use. |
Abort a copy.
| ptr | The pointer returned by copy(). |
|
inlinenoexcept |
Add an old copy.
This function will manage old copies. It will keep a list of copies that are still being used, and destroy and deallocate old copies that are no longer being used.
| old_version | The version when the pointer was exchanged. |
| old_ptr | The pointer that was exchanged, may be a nullptr. |
Number of objects that are currently allocated.
This function is useful in tests to determine if the old copies are properly deallocated.
Commit the copied value.
| ptr | The pointer returned by copy(). |
Create a copy of the value.
Create a copy of the value at the given pointer.
| ptr | The pointer to a value to copy. |
Emplace a new value.
This function will allocate and construct a new value, then replace the current value.
This function will also destroy and deallocate old values when no other threads are reading them.
| args | The arguments passed to the constructor of the value. |
Exchange the rcu-pointers.
| ptr | The new pointer value, may be nullptr. |
get the rcu-pointer.
get the rcu-pointer.
The version of the lock.
add_old_copy().