Wernke zur Borg
2007-07-20 20:40:35 UTC
Imagine an application that plays the role of a relay between a number
of data providers and a number of data consumers. Data providers call
methods of the relay to deliver data. Data consumers call methods on the
relay to fetch data. The relay has a queue for buffering the data. The
data structures are the same for both sides, say:
// IDL
struct Data {
...
};
The relay interface for the data providers is something like:
// IDL
interface DataRelay {
void putData( in Data d ); // queues the data
};
The relay interface for the data consumers is something like:
// IDL
interface DataRelay {
Data getData(); // delivers first item from queue
};
The C++ equivalent for this interface is
// C++
void DataRelay::putData( const Data& d );
Data* DataRelay::getData();
The problem with this is that each data item must be copied at least
once during putData(). Since performance is an issue in my case I am
looking for a way to minimise copying the data. However with the const
argument& I do not see a way to avoid it.
Any ideas?
Regards, Wernke
of data providers and a number of data consumers. Data providers call
methods of the relay to deliver data. Data consumers call methods on the
relay to fetch data. The relay has a queue for buffering the data. The
data structures are the same for both sides, say:
// IDL
struct Data {
...
};
The relay interface for the data providers is something like:
// IDL
interface DataRelay {
void putData( in Data d ); // queues the data
};
The relay interface for the data consumers is something like:
// IDL
interface DataRelay {
Data getData(); // delivers first item from queue
};
The C++ equivalent for this interface is
// C++
void DataRelay::putData( const Data& d );
Data* DataRelay::getData();
The problem with this is that each data item must be copied at least
once during putData(). Since performance is an issue in my case I am
looking for a way to minimise copying the data. However with the const
argument& I do not see a way to avoid it.
Any ideas?
Regards, Wernke