I
ittium
I want to pass data between two threads. Type of data can vary.
data
{
list l;
map m;
}
data
{
int i;
long l;
}
I can think of following ways to do it
1. write serialise routines so that between the thread, encoded void*
buffer is passed. But since thread will run in same address space,
serialization seems to me as overkill.
2. Pass a token (specifying the type) and data typecasted to void*.
Receiving thread can typecast the data to actual type based on the
token
3. Use boost:any and then receiver can find out type using RTTI.
Since large amount of data is to be processed, CPU utilization is
important concern.
Can you comment, which of these approach will be good. I am open to
considering any approach other than above three.
I will appreciate your experiences of solving similar problem.
thanks
Ittium
data
{
list l;
map m;
}
data
{
int i;
long l;
}
I can think of following ways to do it
1. write serialise routines so that between the thread, encoded void*
buffer is passed. But since thread will run in same address space,
serialization seems to me as overkill.
2. Pass a token (specifying the type) and data typecasted to void*.
Receiving thread can typecast the data to actual type based on the
token
3. Use boost:any and then receiver can find out type using RTTI.
Since large amount of data is to be processed, CPU utilization is
important concern.
Can you comment, which of these approach will be good. I am open to
considering any approach other than above three.
I will appreciate your experiences of solving similar problem.
thanks
Ittium