15enum class WorkType : uint8_t {
24static_assert(
static_cast<uint8_t
>(WorkType::WorkTypeMax) <= 8,
25 "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);
36inline std::pair<void *, WorkType> decode_work(uintptr_t ptr)
noexcept {
37 uintptr_t mask = (1 << 3) - 1;
38 WorkType type =
static_cast<WorkType
>(ptr & mask);
40 void *addr =
reinterpret_cast<void *
>(ptr & (~mask));
41 return std::make_pair(addr, type);
45inline uintptr_t encode_work(T *ptr, WorkType type)
noexcept {
46 static_assert(std::alignment_of_v<T> >= 8,
47 "Pointer must be at least 8-byte aligned");
48 return detail::encode_work_ptr(
reinterpret_cast<uintptr_t
>(ptr), type);
51inline uintptr_t encode_work(std::nullptr_t, WorkType type)
noexcept {
52 return detail::encode_work_ptr(0, type);
The main namespace for the Condy library.