A
Andy
Hello,
I have the following situation:
Thread A is allocating a dataset, doing some low-level calculations
and storing a pointer to the dataset in a std::list via push_back.
Thread B should retrieve the pointer to the first dataset in the list,
remove it from the list, and do some high level analysis.
The problem now is, how do I efficiently retrieve the pointer?
Calling front() and then pop_front() deletes the dataset, i.e. calls
its destructor, so this is not good, since I don't want to copy the
datasets before calling pop_front(), because they are very large...
Calling front() and remove(mylist.front()) does the job, but loops
through the whole list and is thus also not very efficient..
Is there any efficient way to retrieve the first object from the list,
and remove the object then from the list, without looping through the
whole list or deleting the object?
If anybody has a good answer to the problem, I would really appreciate
to hear it.
Thanks a lot,
Andy
I have the following situation:
Thread A is allocating a dataset, doing some low-level calculations
and storing a pointer to the dataset in a std::list via push_back.
Thread B should retrieve the pointer to the first dataset in the list,
remove it from the list, and do some high level analysis.
The problem now is, how do I efficiently retrieve the pointer?
Calling front() and then pop_front() deletes the dataset, i.e. calls
its destructor, so this is not good, since I don't want to copy the
datasets before calling pop_front(), because they are very large...
Calling front() and remove(mylist.front()) does the job, but loops
through the whole list and is thus also not very efficient..
Is there any efficient way to retrieve the first object from the list,
and remove the object then from the list, without looping through the
whole list or deleting the object?
If anybody has a good answer to the problem, I would really appreciate
to hear it.
Thanks a lot,
Andy