13enum class WorkType : uint8_t {
23inline std::pair<void *, WorkType> decode_work(
void *ptr) {
24 intptr_t mask = (1 << 3) - 1;
25 intptr_t addr =
reinterpret_cast<intptr_t
>(ptr);
26 WorkType type =
static_cast<WorkType
>(addr & mask);
28 void *actual_ptr =
reinterpret_cast<void *
>(addr & (~mask));
29 return std::make_pair(actual_ptr, type);
32inline void *encode_work(
void *ptr, WorkType type) {
33 intptr_t addr =
reinterpret_cast<intptr_t
>(ptr);
35 assert(addr % 8 == 0);
36 addr |=
static_cast<intptr_t
>(type);
38 return reinterpret_cast<void *
>(addr);
The main namespace for the Condy library.
Definition condy.hpp:28