laforge49/JActor — Issue #15: Atomic component--a non-blocking lock
Author: laforge49
Created: 2012-03-02 03:37:23+00:00
State: open

The atomic component will have two requests, begin and end. Begin requests are added to a queue; end requests pop the queue.

If the queue is empty when a begin request is received, it gets an immediate response. Otherwise it receives a response when the queue is popped and the begin request is now on top.

The Atomic component serves as a non-blocking lock. To use it, you send a begin request with a callback. Once the callback is invoked you have exclusive access to some resource, but when done you need to send an end request. But note that no threads are blocked while the response from the begin is pending.