RWTIOUResult
Class
RWTIOUResult allows a function in one thread to return immediately, while the code that supplies the actual result continues to run in a new thread. The
RWTIOUResult instance may be redeemed immediately, as shown in the following example:
RWFtpReply r = ftp.cd("pub");
This function actually returns an object of type
RWTIOUResult<RWFtpReply>, which is immediately converted to the redeemable type
RWFtpReply. If the redeemable type is available at the time when
RWFtpReply is assigned, the call does not block and the redeemable is returned. If the redeemable is not available yet (that is, the thread processing the request has not finished), then the call blocks in the assignment statement until the redeemable is available.
Under some circumstances, you may want your application to do other processing instead of waiting until the result is received. In the following example, the result of the
cd method is assigned to an
RWTIOUResult:
// Get the IOU that will eventually contain the result
RWTIOUResult<RWFtpReply> iou = ftp.cd("pub");
...
// Perform other processing
...
// Redeem the IOU and get the result
RWFtpReply r = iou; // or RWFtpReply r = iou.redeem();
The IOU can be redeemed when you are ready to use the result.