thread: Test for pending cancellation requests before poll()ing on OS X

As we are now using poll(2) instead of select(2), we need the work-around from
76dc329e for poll() as well.