SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
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 (const RWBodyBase &second)
 
 RWBodyBase (RWStaticCtor)
 
 RWBodyBase (void)
 
virtual ~RWBodyBase (void)
 
RWBodyBaseoperator= (const RWBodyBase &second)
 
- Protected Member Functions inherited from RWTCountingBody< RWMutexLock >
 RWTCountingBody (const RWTCountingBody< RWMutexLock > &second)
 
 RWTCountingBody (RWStaticCtor)
 
 RWTCountingBody (unsigned initCount=0)
 
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 (const RWTMonitor< RWMutexLock > &second)
 
 RWTMonitor (RWStaticCtor)
 
 RWTMonitor (void)
 
 ~RWTMonitor (void)
 
void acquire (void)
 
bool isAcquired (void) const
 
RWTMonitor< RWMutexLock > & monitor (void) const
 
RWMutexLockmutex (void)
 
RWTMonitor< RWMutexLock > & operator= (const RWTMonitor< RWMutexLock > &)
 
void release (void)
 
bool tryAcquire (void)
 

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

◆ RedeemableType

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

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

◆ RWTIOUResultCallback

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

A typedef for a callback function object.

Constructor & Destructor Documentation

◆ ~RWTEscrowImp()

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

Virtual destructor.

◆ RWTEscrowImp()

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

◆ abort()

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.

◆ aborted()

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

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

◆ addCallback()

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

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

◆ close()

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.

◆ closeable()

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.

◆ closed()

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.

◆ inError()

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.

◆ newInstance()

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

Creates a new instance of this RWTEscrowImp type.

◆ redeem()

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.

◆ redeemable()

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.

◆ redeemed()

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.

◆ removeCallback()

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

Removes the callback if it exists, otherwise does nothing.

◆ setException()

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 © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.