Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

RWTIOUTrap<Redeemable>


RWTIOUTrap<Redeemable> RWHandleBase

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Member Functions

Package

Interthread Communication

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

Constructors

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

Destructor

~RWTIOUTrap(void);

Public Member Operator

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

Public Member Functions

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

Static Public Member Function

static
RWTIOUTrap<Redeemable>
make(void);

Protected Constructor

RWTIOUTrap(RWTIOUTrapImp<Redeemable>* iouTrapImpP);

See Also

RWTIOUResult<Redeemable>



Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.