13enum class WorkType : uint8_t {
22static_assert(
static_cast<uint8_t
>(WorkType::WorkTypeMax) <= 8,
23 "WorkType must fit in 3 bits");
25inline std::pair<void *, WorkType> decode_work(
void *ptr)
noexcept {
26 intptr_t mask = (1 << 3) - 1;
27 intptr_t addr =
reinterpret_cast<intptr_t
>(ptr);
28 WorkType type =
static_cast<WorkType
>(addr & mask);
30 void *actual_ptr =
reinterpret_cast<void *
>(addr & (~mask));
31 return std::make_pair(actual_ptr, type);
34inline void *encode_work(
void *ptr, WorkType type)
noexcept {
35 intptr_t addr =
reinterpret_cast<intptr_t
>(ptr);
37 assert(addr % 8 == 0);
38 addr |=
static_cast<intptr_t
>(type);
40 return reinterpret_cast<void *
>(addr);
The main namespace for the Condy library.