In file future.hxx:

namespace vos template class OFuture : public VOS_NAMESPACE OReferenceCounter, vos

OFuture, OFutureRef A future represents the result of an asynchronous operation

Inheritance:


Public Methods

void dataValid ()
Declare the data stored in the future as valid
T getData ()
Access the data stored within the future
T* getDataPtr ()
Get a pointer to the data stored within the future
void setData (const T& data)
Assign data to the future

Documentation

OFuture, OFutureRef A future represents the result of an asynchronous operation. It allows one or several "consumers" or "users" of that result to be blocked only if they actually need to access the result and only if the result has not yet been computed by the asynchronous operation. Consider a web-browser with seperate threads for downloading and viewing pictures. The downloading thread offers its result (the picture data) as a "future". If the display-threads trys to access the data, it is blocked until the download-thread declares the data as valid. Now we might have several threads, unaware of each other, wanting to use the same data. How should one of these threads know when it's safe to delete the data represented by the future? To solve this problem, we use reference-counting on the future object. To hide the difficulties of calling addRef/reseaseRef operations from the user, we use OFutureRef-Objects instead of OFutures. The first created OFutureRef-Object actually creates the OFuture. Now we can make as much copies of this OFutureRef-Object as are needed, with each copy only the reference-count of the underlying OFuture is increased. Each thread done with its OFutureRef can just delete it (or let it run out of scope, if created on the stack). Only if the last OFutureRef is gone, the OFuture will be deleted.
void setData(const T& data)
Assign data to the future. You should do this BEFORE declaring the futures data valid!

T getData()
Access the data stored within the future. If the data has not been declared valid, the calling thread will be blocked.

T* getDataPtr()
Get a pointer to the data stored within the future. If the data has not been declared valid, the calling thread will be blocked.

void dataValid()
Declare the data stored in the future as valid. Any thread waiting on a getData-/getDataPtr-call will continue running now.


This class has no child classes.
Author:
Bernd Hofner
Version:
0.1

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de