Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Threads Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWTIOUResult<Redeemable>

Module:  Threads   Package:  Interthread Communication


RWTIOUResult<Redeemable> RWTEscrowHandle<Redeemable>

Local Index

Members

Header File

#include <rw/itc/RWTIOUResult.h> 

Description

An RWTIOUResult<Redeemable> is a readable IOU handle. An IOU, sometimes known as a future, is a promise for a value that is forthcoming. It is a placeholder for that value. Usually the writer of an IOU and the reader (or readers) of an IOU are in different threads of control. In this sense IOUs are a mechanism for interthread communication.

The template parameter Redeemable is the value type of IOU result. This type must provide a public copy-constructor and must allow dynamic allocation using operator new().

An IOU is a write once/read many structure. It may only be written to once, but may be read any number of times.

The RWTIOUResult<Redeemable> handle is a reference counted handle to an RWTEscrowImp<Redeemable>. It can be copied and passed by value. When the last handle to a given RWTEscrowImp<Redeemable> is destroyed, then the internal RWTEscrowImp<Redeemable> is destroyed.

An RWTIOUResult<Redeemable> can be initialized by or assigned to an RWTIOUEscrow<Redeemable>, and visa versa. Both are interfaces to the same underlying RWTIOUEscrowImp<Redeemable>. RWTIOUResult<Redeemable> is a read interface, and RWTIOUEscrow<Redeemable> is a write interface.

The holder of the RWTIOUResult<Redeemable> decides how and when to redeem the value held by the IOU. IOU redemption is the process of getting the result from the IOU when it is available. There are 3 ways to redeem an RWTIOUResult<Redeemable>:

An IOU may be aborted by the holder of an RWTIOUResult<Redeemable>. This will cause an exception to be thrown if an attempt is made to redeem the IOU or to set its value.

Similarly an exception may be set on an IOU by the holder of an RWTIOUEscrow<Redeemable>. This will cause the exception to be thrown when an attempt is made to redeem it.

An RWTIOUResult<Redeemable> is redeemable if a value has been set, if it has been aborted, or if an exception has been set.

Example

Public Typedefs

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

Public Constructors

RWTIOUResult();
RWTIOUResult(const RWTEscrowHandle<Redeemable>& escrowHandle);
RWTIOUResult(const RWTIOUResult<Redeemable>& second);

Public Destructor

~RWTIOUResult()

Public Member Operators

RWTIOUResult<Redeemable>&
operator=(const RWTIOUResult<Redeemable>& second)
Redeemable
operator()() const;
operator Redeemable() const;

Public Member Functions

void
abort() const;
bool
aborted() const;
void
addCallback(const RWTIOUResultCallback& callback)
bool
inError() const;
Redeemable
redeem() const;
bool
redeemable() const;
bool
redeemed() const;
void
removeCallback(const RWTIOUResultCallback& callback);

See Also

RWTIOUEscrow<Redeemable>, RWTEscrowHandle<Redeemable>, RWTEscrowImp<Redeemable>, RWTThreadEscrowImp<Redeemable>, rwtMakeIOUCallback()



Previous fileTop of DocumentContentsIndex pageNext file

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