SourcePro® API Reference Guide

 
List of all members | Public Types | Public Member Functions | Protected Member Functions
RWTEscrowImp< Redeemable > Class Template Referenceabstract

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 >

Public Types

typedef Redeemable RedeemableType
 
typedef RWTFunctor< void(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)
 
- Protected Member Functions inherited from RWEscrowImpBase
 RWEscrowImpBase (void)
 
virtual ~RWEscrowImpBase (void)
 
- Protected Member Functions inherited from RWBodyBase
 RWBodyBase (void)
 
 RWBodyBase (RWStaticCtor)
 
 RWBodyBase (const RWBodyBase &second)
 
virtual ~RWBodyBase (void)
 
RWBodyBaseoperator= (const RWBodyBase &second)
 
- Protected Member Functions inherited from RWTCountingBody< RWMutexLock >
 RWTCountingBody (unsigned initCount=0)
 
 RWTCountingBody (RWStaticCtor)
 
 RWTCountingBody (const RWTCountingBody< RWMutexLock > &second)
 
RWTCountingBody< RWMutexLock > & operator= (const RWTCountingBody< RWMutexLock > &second)
 
 ~RWTCountingBody (void)
 
unsigned addReference (void)
 
unsigned references (void) const
 
unsigned removeReference (void)
 
- Protected Member Functions inherited from RWTMonitor< RWMutexLock >
 RWTMonitor ()
 
 RWTMonitor (RWStaticCtor)
 
 RWTMonitor (const RWTMonitor< RWMutexLock > &second)
 
 ~RWTMonitor ()
 
void acquire ()
 
bool isAcquired () const
 
RWTMonitor< RWMutexLock > & monitor () const
 
RWMutexLockmutex ()
 
RWTMonitor< RWMutexLock > & operator= (const RWTMonitor< RWMutexLock > &)
 
void release ()
 
bool tryAcquire ()
 

Additional Inherited Members

- Protected Types inherited from RWTCountingBody< RWMutexLock >
typedef RWTLockGuard< RWTMonitor< RWMutexLock > > LockGuard
 
typedef RWTTryLockGuard< RWTMonitor< RWMutexLock > > TryLockGuard
 
typedef RWTUnlockGuard< RWTMonitor< RWMutexLock > > UnlockGuard
 
- Protected Types inherited from RWTMonitor< RWMutexLock >
typedef RWTLockGuard< RWTMonitor< RWMutexLock > > LockGuard
 
typedef RWTTryLockGuard< RWTMonitor< RWMutexLock > > TryLockGuard
 
typedef RWTUnlockGuard< RWTMonitor< RWMutexLock > > UnlockGuard
 

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 and RWTIOUEscrow handles. The interface of RWTEscrowImp is a union of the interfaces provided by RWTIOUResult and RWTIOUEscrow.

Member Typedef Documentation

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

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

template<class Redeemable >
typedef RWTFunctor<void(RWTEscrowHandle<Redeemable>)> RWTEscrowImp< Redeemable >::RWTIOUResultCallback

A typedef for a callback function object.

Constructor & Destructor Documentation

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

Virtual destructor.

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

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

This type of construction means that a raw RWTEscrowImp 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
RWTHREscrowAlreadyClosedThrown if the escrow has already been closed.
RWTHROperationAbortedThrown 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 type.

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

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

Exceptions
RWTHROperationAbortedThrown 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.

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.