Async Events and the Scheduler

When an async event is fired, the scheduler should activate all the async event handlers bound to that async event and increment a fire count associated with that handler. Each handler should remain active until its fire count reaches zero. Normally, the handler will just complete its handleAsyncEvent method, drop out the end, and become inactive, but if it is fired fast enough, the fire count may become greater than 1. In that case, some of the details of the wrapper for handleAsyncEvent become visible:

do {
  handleAsyncEvent();
} while getAndDecrementPendingFireCount() > 1)

At first glance, it looks like the test in the while should be for > 0, or maybe even ≥, 0, but the test is after a call to handleAsyncEvent, ...

Get Real-Time Java™ Platform Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.