An 8-byte pointer with an integrated spin lock and 15-bit integer.
Declared in <folly/PackedSyncPtr.h>
template<class T>
class PackedSyncPtr;
This packs a raw pointer, a spin lock, and 15 bits of extra storage into a single 8-byte word by reusing the always-zero upper bytes of a 64-bit virtual address. It is not a smart pointer: locking and deallocation are up to the user, and locks are only acquired or released through explicit lock() and unlock() calls.
| Name | Description |
|---|---|
extra | Returns the extra data stored in the unused bytes of the pointer. |
get | Returns the stored raw pointer. |
init | Initializes a default-constructed instance before first use. |
lock | Acquires the integrated spin lock, blocking until it is held. |
operator* | Dereferences the stored raw pointer. |
operator-> | Returns the stored raw pointer for member access. |
operator[] | Accesses an element relative to the stored raw pointer. |
set | Sets a new raw pointer. |
setExtra | Stores extra data in the unused bytes of the pointer. |
try_lock | Attempts to acquire the integrated spin lock without blocking. |
unlock | Releases the integrated spin lock. |