Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

The semantics of TBB's conaintainers

Kubera
Beginner
349 Views

Hi!

Could Someone answer my question, please?

I have added a concurrent map to my project. The question is, how many instances of one single value would be temporarilly existing while modifing the data of container (for example, insert() method)? The qestion is not about copy/move semtantics. I have read, that movable semantics is not impleneted int the TBB yet. Is there a reference counting important for the values? Would it be possible to create the movable constructor and the operator and disable the copy ctor and operator?

Maybe someone would answer my qestion and consider writting a few words about the architecture of TBB.

Thank you very much and Happy Christmass

0 Kudos
5 Replies
RafSchietekat
Valued Contributor III
349 Views
You have to be specific about the kind of map: concurrent_hash_map or concurrent_unordered_map?
0 Kudos
Kubera
Beginner
349 Views
I am using a concurrent_hash_map template.
0 Kudos
RafSchietekat
Valued Contributor III
349 Views
For concurrent_hash_map it is possible for several threads to have accessors to elements with the same key that are not part of the map anymore because other threads erase()'d them. This is mentioned in the Reference Manual: in the version I downloaded a while ago there is a CAUTION that: "Though there can be at most one occurrence of a given key in the map, there may be other key-value pairs in flight with the same key. These arise from the semantics of the insert and erase methods. The insert methods can create and destroy a temporary key-value pair that is not inserted into a map. The erase methods remove a key-value pair from the map before destroying it, thus permitting another thread to construct a similar key before the old one is destroyed.".
0 Kudos
Kubera
Beginner
349 Views
I highly appreciate the answer. It would be enough for me.
0 Kudos
Kubera
Beginner
349 Views
This thread would be closed. How it would be done?
0 Kudos
Reply