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

RWTIOUTrap<Redeemable>

Module:  Threads   Package:  Interthread Communication


RWTIOUTrap<Redeemable> RWHandleBase

Local Index

Members

Header File

#include <rw/itc/RWTIOUTrap.h>

Description

RWTIOUTrap<Redeemable> allows you to wait for next IOU in a group of IOUs to become redeemable. For example, it can be used to wait on IOU results from a number of RWThreadIOUFunction instances. You may either block waiting for the next IOU to become available, wait with a time-out, or poll for the next IOU.

RWTIOUTrap<Redeemable> assists in the management of a number of RWTIOUResult instances. Without an IOU trap, you would have to poll each of a number of IOUs in turn, testing to see when the next one becomes redeemable. This kind of polling loop, however, is inefficient in a multithreaded environment. With an IOU trap, you merely wait for the trap to provide you with the next redeemable IOU.

Each IOU you wish to trap must first be registered using the setTrap() member function. Once an IOU is registered, it will automatically notify the trap when it becomes redeemable. RWTIOUTrap<Redeemable> uses a producer-consumer queue to store each IOU as they notify the trap that they are redeemable. An RWTIOUResult<Redeemable> is inserted into the queue by the thread that closed it, and taken off the queue when the trap's getNext() member is called.

The IOU trap is an implemented handle-body object. The RWTIOUTrap<Redeemable> is the handle for an IOU trap object. These handles allow a trap to be passed and shared by value. The actual trap object is deleted when the last handle that references it is destroyed.

Example

Public Constructors

RWTIOUTrap();
RWTIOUTrap(RWStaticCtor);
RWTIOUTrap(const RWTIOUTrap<Redeemable>& second);

Public Destructor

~RWTIOUTrap();

Public Member Operator

RWTIOUTrap<Redeemable>&
operator=(const RWTIOUTrap<Redeemable>& second)

Public Member Functions

RWTIOUResult<Redeemable> 
getNext()
RWWaitStatus
getNext(RWTIOUResult<Redeemable>& iouResult, 
        unsigned long milliseconds);
bool 
isEmpty() const;
void
setTrap(RWTIOUResult<Redeemable> iou) const;
bool
tryGetNext(RWTIOUResult<Redeemable>& iouResult);

See Also

RWTIOUResult<Redeemable>



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.