Module: Threads Package: Interthread Communication
RWTEscrowImp<Redeemable> RWEscrowImpBase
#include <rw/itc/RWTEscrowImp.h>
RWTEscrowImp<Redeemable> serves as the base class for all concrete IOU escrow implementations. It provides basic functionality and allows for extension via virtual functions.
This class should never be used directly. It should only be used through RWTIOUResult<R> and RWTIOUEscrow<R> handles. The interface of RWTEscrowImp<R> is a union of the interfaces provided by RWTIOUResult<R> and RWTIOUEscrow<R>.
typedef Redeemable RedeemableType; typedef RWTFunctor1<RWTEscrowHandle<Redeemable>> RWTIOUResultCallback;
virtual ~RWTEscrowImp();
Virtual destructor.
void abort();
Tells the service provider that the result is no longer needed. Notifies anyone waiting on the IOU, so they can detect abort and catch an exception. Subsequent calls to redeem the IOU will immediately receive an exception, indicating that the operation associated with the Escrow has been aborted. Ignored if the operation was already aborted.
bool aborted() const;
Returns true if the operation has been aborted.
void addCallback(const RWTIOUResultCallback& iouResultCallback);
Adds a callback. The callback is fired when the Escrow is closed.
void close(const Redeemable& value);
Stores a value into the Escrow. If the Escrow has already been closed then an RWTHREscrowAlreadyClosed exception will be thrown. If the escrow operation has been aborted, then an RWTHROperationAborted exception is thrown. If an exception has been set, then that exception is thrown.
bool closeable() const;
Can a value be written into the Escrow? true if no value has been written and the escrow isn't in error or aborted.
bool closed() const;
Has a value been successfully written into the Escrow? (Note that redeemable() or !closeable() is better for polling as they will inform of errors and abortion in addition to valid closures).
bool inError() const;
Was the Escrow closed with an error? If it was, then the function returns true and the caller can expect an exception to be thrown on the next call to redeem.
RWTEscrowHandle<Redeemable> newInstance() const;
Creates a new instance of this RWTEscrowImp<Redeemable> type. Implemented by most derived types.
const Redeemable& redeem() const;
Gets the result, blocking if the result is not yet available. Throws RWTHROperationAborted if the Escrow (or the associated operation) has been aborted. If an exception is thrown and stored in the Escrow, then that exception is re-thrown by this routine.
bool redeemable() const;
Returns true if a proper value has been set, if an error has been set, or if the operation has been aborted. This function is used primarily by the reader side to poll the Escrow for the availability of a result.
bool redeemed() const;
Returns whether the result has been successfully redeemed. Note that redemption that results in the throwing of an exception does not count as a success.
void removeCallback(const RWTIOUResultCallback& iouResultCallback);
Removes callback if it exists; otherwise does nothing.
void setException(const RWTHRxmsg& xmsg);
Sets an error on the Escrow and causes an exception to be stored inside the Escrow. Notifies callers waiting for the Escrow to be closed so that they can redeem the IOU and catch the error. If the Escrow has already been closed normally, closed with an error, or aborted, then the error is ignored.
RWTEscrowImp();
RWTEscrowImp<R> may not be explicitly constructed. It may only be constructed implicitly using make() functions in concrete derived classes. The derived-class make() functions return an RWTEscrowHandle<R> for initializing an RWTIOUEscrow<R> or RWTIOUResult<R>. This means that, under normal circumstances, you will never see a raw RWTEscrowImp<Redeemable> pointer.
RWTIOUResult<Redeemable>, RWTIOUEscrow<Redeemable>, RWTEscrowHandle<Redeemable>, RWTThreadEscrowImp<Redeemable>
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.