Balking Pattern

Intent: Return control immediately, with appropriate indication, if an object is invoked when it is not in an appropriate state to execute the method.

In java, one might consider throwing a java.lang.IllegalStateException (this is an unchecked exception, which might be good or bad).


I do not see the connection to ReadWriteLock! (reference in "See also" below)?

One way of implementing BalkingPattern would be to attempt to get a Write lock, with a timeout. If getting the lock times out, it is assumed the object is not in an appropriate state to execute the method.


See also: LockPattern, GuardedSuspension, SpinLock


CategoryPattern | CategoryBehavioralPatterns | CategoryConcurrencyPatterns


EditText of this page (last edited November 18, 2011) or FindPage with title or text search