1 #ifndef NDNDPDK_DPDK_THREAD_H
2 #define NDNDPDK_DPDK_THREAD_H
6 #include "../core/common.h"
17 static __rte_always_inline
void
19 #ifdef NDNDPDK_THREADSLEEP
32 sleepFor = RTE_MAX(sleepFor, (uint64_t)ctrl->
sleepFor + 1);
36 struct timespec req = {.tv_sec = 0, .tv_nsec = ctrl->
sleepFor};
37 nanosleep(&req, NULL);
43 static __rte_always_inline
void
45 #ifdef NDNDPDK_THREADSLEEP
58 #define ThreadCtrl_Continue(ctrl, count) \
60 ++(ctrl).nPolls[(int)((count) > 0)]; \
61 (ctrl).items += (count); \
63 ThreadCtrl_Sleep(&(ctrl)); \
65 ThreadCtrl_SleepReset(&(ctrl)); \
68 atomic_load_explicit(&(ctrl).stop, memory_order_acquire); \
71 __attribute__((nonnull))
static inline void
74 atomic_init(&ctrl->
stop,
true);
77 __attribute__((nonnull))
static inline void
79 atomic_store_explicit(&ctrl->
stop,
false, memory_order_release);
82 __attribute__((nonnull))
static inline void
84 atomic_store_explicit(&ctrl->
stop,
true, memory_order_release);
Thread load stats and stop flag.
Definition: thread.h:10
atomic_bool stop
Definition: thread.h:14
uint32_t sleepFor
Definition: thread.h:13
uint64_t items
Definition: thread.h:12
uint64_t nPolls[2]
Definition: thread.h:11
@ ThreadCtrl_SleepAdd
Definition: thread-enum.h:12
@ ThreadCtrl_SleepMax
Definition: thread-enum.h:8
@ ThreadCtrl_SleepMultiply
Definition: thread-enum.h:10
@ ThreadCtrl_SleepMin
Definition: thread-enum.h:7
@ ThreadCtrl_SleepAdjustEvery
Definition: thread-enum.h:9
@ ThreadCtrl_SleepDivide
Definition: thread-enum.h:11
struct ThreadCtrl ThreadCtrl
Thread load stats and stop flag.