RWTEscrowImp<Redeemable> RWEscrowImpBase
abort() aborted() addCallback() close() |
closeable() closed() inError() newInstance() |
redeem() redeemable() redeemed() removeCallback() |
setException() |
#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;
RWTEscrowImp(void)
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, the library user will never see a raw RWTEscrowImp<Redeemable> pointer.
virtual ~RWTEscrowImp(void);
Virtual destructor.
void abort(void);
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.
RWBoolean aborted(void) 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(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.
RWBoolean closeable(void) 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.
RWBoolean closed(void) 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).
RWBoolean 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(void) const;
Creates a new instance of this RWTEscrowImp<Redeemable> type. Implemented by most derived types.
Redeemable redeem(void) 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.
RWBoolean redeemable(void) 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.
RWBoolean redeemed(void) 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.
void setException(const RWCString& msg);
Sets the error with a string. The string is packaged into an RWTHRxmsg and stored within the RWTEscrowImp<Redeemable> until it is redeemed, at which point it is thrown. If the Escrow has already been either closed normally, closed with an error, or aborted, then the error is ignored.
RWTIOUResult<Redeemable>, RWTIOUEscrow<Redeemable>, RWTEscrowHandle<Redeemable>, RWTThreadEscrowImp<Redeemable>
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.