17enum class WorkType : uint8_t {
26static_assert(
static_cast<uint8_t
>(WorkType::WorkTypeMax) <= 8,
27 "WorkType must fit in 3 bits");
29inline uintptr_t encode_work_ptr(uintptr_t ptr, WorkType type)
noexcept {
30 assert((ptr % 8) == 0);
31 return ptr |
static_cast<uintptr_t
>(type);
34inline std::pair<void *, WorkType> decode_work(uintptr_t ptr)
noexcept {
35 uintptr_t mask = (1 << 3) - 1;
36 WorkType type =
static_cast<WorkType
>(ptr & mask);
38 void *addr =
reinterpret_cast<void *
>(ptr & (~mask));
39 return std::make_pair(addr, type);
43inline uintptr_t encode_work(T *ptr, WorkType type)
noexcept {
44 static_assert(std::alignment_of_v<T> >= 8,
45 "Pointer must be at least 8-byte aligned");
46 return encode_work_ptr(
reinterpret_cast<uintptr_t
>(ptr), type);
49inline uintptr_t encode_work(std::nullptr_t, WorkType type)
noexcept {
50 return encode_work_ptr(0, type);
The main namespace for the Condy library.