rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWTEscrowImp< Redeemable > Class Template Reference
[Interthread Communication]

Base class for all concrete IOU escrow implementations. Not intended for direct use. More...

#include <rw/itc/RWTEscrowImp.h>

Inheritance diagram for RWTEscrowImp< Redeemable >:
RWEscrowImpBase RWBodyBase RWTCountingBody< RWMutexLock > RWTMonitor< RWMutexLock > RWTThreadEscrowImp< Redeemable >

List of all members.

Public Types

typedef Redeemable RedeemableType
typedef RWTFunctor1
< RWTEscrowHandle< Redeemable > > 
RWTIOUResultCallback

Public Member Functions

virtual ~RWTEscrowImp (void)
void abort (void)
bool aborted (void) const
void addCallback (const RWTIOUResultCallback &iouResultCallback)
void close (const Redeemable &value)
bool closeable (void) const
bool closed (void) const
bool inError (void) const
RWTEscrowHandle< Redeemable > newInstance (void) const
const Redeemable & redeem (void) const
bool redeemable (void) const
bool redeemed (void) const
void removeCallback (const RWTIOUResultCallback &iouResultCallback)
void setException (const RWTHRxmsg &xmsg)

Protected Member Functions

 RWTEscrowImp (void)

Detailed Description

template<class Redeemable>
class RWTEscrowImp< Redeemable >

Do not use this class directly. This class is the base class for all concrete IOU escrow implementations, providing basic functionality and allowing for extension via virtual functions.

Use this class only through RWTIOUResult<Redeemable> and RWTIOUEscrow<Redeemable> handles. The interface of RWTEscrowImp<Redeemable> is a union of the interfaces provided by RWTIOUResult<Redeemable> and RWTIOUEscrow<Redeemable>.


Member Typedef Documentation

template<class Redeemable >
typedef Redeemable RWTEscrowImp< Redeemable >::RedeemableType

A synonym for the value type of the IOU, or future, result.

Reimplemented in RWTThreadEscrowImp< Redeemable >.

template<class Redeemable >
typedef RWTFunctor1< RWTEscrowHandle<Redeemable> > RWTEscrowImp< Redeemable >::RWTIOUResultCallback

A typedef for a callback function created by rwtMakeIOUCallback().


Constructor & Destructor Documentation

template<class Redeemable >
virtual RWTEscrowImp< Redeemable >::~RWTEscrowImp ( void   )  [virtual]

Virtual destructor.

template<class Redeemable >
RWTEscrowImp< Redeemable >::RWTEscrowImp ( void   )  [protected]

RWTEscrowImp<Redeemable> cannot be explicitly constructed. Rather, construct it implicitly using make() functions in concrete derived classes. The derived-class make() functions return an RWTEscrowHandle<Redeemable> for initializing an RWTIOUEscrow<Redeemable> or RWTIOUResult<Redeemable>.

This type of construction means that a raw RWTEscrowImp<Redeemable> pointer will not be visible to your application.


Member Function Documentation

template<class Redeemable >
void RWTEscrowImp< Redeemable >::abort ( void   ) 

Aborts the operation associated with the escrow, as follows:

  • Tells the service provider that the result is no longer needed.
  • Notifies all entities waiting on the IOU, so they can detect the abort and catch an exception.
  • Sends an exception to all subsequent calls to redeem the IOU, indicating that the operation has been aborted.

This method is ignored if the operation has already been aborted.

template<class Redeemable >
bool RWTEscrowImp< Redeemable >::aborted ( void   )  const

Returns true if the operation has been aborted, otherwise false.

template<class Redeemable >
void RWTEscrowImp< Redeemable >::addCallback ( const RWTIOUResultCallback iouResultCallback  ) 

Adds a callback. The callback is fired when the escrow is closed.

template<class Redeemable >
void RWTEscrowImp< Redeemable >::close ( const Redeemable &  value  ) 

Stores the value, then closes the escrow. If an exception has been set, that exception is thrown.

Exceptions:
RWTHREscrowAlreadyClosed Thrown if the escrow has already been closed.
RWTHROperationAborted Thrown if the escrow operation has been aborted.
template<class Redeemable >
bool RWTEscrowImp< Redeemable >::closeable ( void   )  const

Returns true if the escrow can be closed, i.e. if no value has been stored into the escrow, and the escrow is not in the error or aborted states. Otherwise, returns false.

template<class Redeemable >
bool RWTEscrowImp< Redeemable >::closed ( void   )  const

Returns true if a value has been stored, and the escrow is closed. Otherwise, returns false.

Note:
The methods redeemable() or !closeable() are better for polling as they report errors and abortion, in addition to valid closures.
template<class Redeemable >
bool RWTEscrowImp< Redeemable >::inError ( void   )  const

Returns true if the escrow closed with an error, otherwise false. If the escrow did close with an error, any subsequent call to redeem receives an exception.

template<class Redeemable >
RWTEscrowHandle<Redeemable> RWTEscrowImp< Redeemable >::newInstance ( void   )  const

Creates a new instance of this RWTEscrowImp<Redeemable> type.

template<class Redeemable >
const Redeemable& RWTEscrowImp< Redeemable >::redeem ( void   )  const

Gets the result, blocking if the result is not yet available.

Exceptions:
RWTHROperationAborted Thrown 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.
template<class Redeemable >
bool RWTEscrowImp< Redeemable >::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; otherwise, returns false.

This function is used primarily by the reader side to poll the escrow for the availability of a result.

template<class Redeemable >
bool RWTEscrowImp< Redeemable >::redeemed ( void   )  const

Returns true if the result has been successfully redeemed; otherwise returns false.

Note:
A redemption that results in an exception being thrown is not counted as a success.
template<class Redeemable >
void RWTEscrowImp< Redeemable >::removeCallback ( const RWTIOUResultCallback iouResultCallback  ) 

Removes the callback if it exists, otherwise does nothing.

template<class Redeemable >
void RWTEscrowImp< Redeemable >::setException ( const RWTHRxmsg xmsg  ) 

Sets an error on the escrow so that an exception is stored inside the escrow. Notifies any callers waiting for the escrow to close so that the callers can redeem the IOU and catch the error. If the escrow has already closed, either normally or abnormally (with an error or by being aborted), then the error is ignored.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© 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.