concurrentqueue icon indicating copy to clipboard operation
concurrentqueue copied to clipboard

Hang when shutting down blocking concurrent queue via interrupt

Open diehard2 opened this issue 10 months ago • 1 comments

When attempting to interrupt a blocking concurrent queue that is waiting on a time out, I'm experiencing a hang (until the timeout) in this line

        do {
#ifdef MOODYCAMEL_LIGHTWEIGHTSEMAPHORE_MONOTONIC
          rc = sem_clockwait(&m_sema, CLOCK_MONOTONIC, &ts);
#else
          rc = sem_timedwait(&m_sema, &ts);
#endif
        } while (rc == -1 && errno == EINTR);
        return rc == 0;

If I change it to respect the interrupt, the timeout doesn't work. However, I'm unable to ctrl-c in my program and shut it down cleanly. What can I do here short of implementing some sort of poll and a smaller timeout?

Also, out of curiosity, is there a benefit to using MOODYCAMEL_LIGHTWEIGHTSEMAPHORE_MONOTONIC?

diehard2 avatar Mar 17 '25 14:03 diehard2