pt icon indicating copy to clipboard operation
pt copied to clipboard

pt_wait - do not suspend if cond true on entry

Open culyun opened this issue 5 years ago • 0 comments

I'm probably missing something but why can't you:

#define pt_wait(pt, cond)                                                      \
 do {                                                                         \
    if ((cond)) {                                     \
      break;                                       \
    }                                                                             \
    pt_label(pt, PT_STATUS_BLOCKED);                                           \
    if (!(cond)) {                                                             \
      return;                                                                  \
    }                                                                          \
  } while (0)

This form would mimic the typical condition-variable signature, which typically does not block if the condition is true.

culyun avatar Dec 18 '20 10:12 culyun