try to minimize contention on hasMessages() call